admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | ''' |
| 3 | Created on 26-Oct-2012 |
| 4 | |
| 5 | @author: Anil Kumar (anilkumar.s@paxterrasolutions.com) |
| 6 | |
| 7 | |
| 8 | TestON is free software: you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation, either version 2 of the License, or |
| 11 | (at your option) any later version. |
| 12 | |
| 13 | TestON is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with TestON. If not, see <http://www.gnu.org/licenses/>. |
| 20 | |
| 21 | |
| 22 | MininetCliDriver is the basic driver which will handle the Mininet functions |
| 23 | ''' |
admin | 2a9548d | 2014-06-17 14:08:07 -0700 | [diff] [blame] | 24 | import traceback |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 25 | import pexpect |
| 26 | import struct |
| 27 | import fcntl |
| 28 | import os |
| 29 | import signal |
| 30 | import re |
| 31 | import sys |
| 32 | import core.teston |
| 33 | sys.path.append("../") |
Jon Hall | 1ccf82c | 2014-10-15 14:55:16 -0400 | [diff] [blame] | 34 | from math import pow |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 35 | from drivers.common.cli.emulatordriver import Emulator |
| 36 | from drivers.common.clidriver import CLI |
| 37 | |
| 38 | class MininetCliDriver(Emulator): |
| 39 | ''' |
Jon Hall | 41f40e8 | 2014-04-08 16:43:17 -0700 | [diff] [blame] | 40 | MininetCliDriver is the basic driver which will handle the Mininet functions |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 41 | ''' |
| 42 | def __init__(self): |
| 43 | super(Emulator, self).__init__() |
| 44 | self.handle = self |
| 45 | self.wrapped = sys.modules[__name__] |
| 46 | self.flag = 0 |
| 47 | |
| 48 | def connect(self, **connectargs): |
Jon Hall | 41f40e8 | 2014-04-08 16:43:17 -0700 | [diff] [blame] | 49 | ''' |
| 50 | Here the main is the TestON instance after creating all the log handles. |
| 51 | ''' |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 52 | for key in connectargs: |
| 53 | vars(self)[key] = connectargs[key] |
| 54 | |
| 55 | self.name = self.options['name'] |
| 56 | self.handle = super(MininetCliDriver, self).connect(user_name = self.user_name, ip_address = self.ip_address,port = None, pwd = self.pwd) |
| 57 | |
| 58 | self.ssh_handle = self.handle |
| 59 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 60 | if self.handle : |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 61 | main.log.info(self.name+": Clearing any residual state or processes") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 62 | self.handle.sendline("sudo mn -c") |
admin | f939f8b | 2014-04-03 17:22:56 -0700 | [diff] [blame] | 63 | i=self.handle.expect(['password\sfor\s','Cleanup\scomplete',pexpect.EOF,pexpect.TIMEOUT],120) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 64 | if i==0: |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 65 | main.log.info(self.name+": Sending sudo password") |
admin | f939f8b | 2014-04-03 17:22:56 -0700 | [diff] [blame] | 66 | self.handle.sendline(self.pwd) |
| 67 | i=self.handle.expect(['%s:'%(self.user),'\$',pexpect.EOF,pexpect.TIMEOUT],120) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 68 | if i==1: |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 69 | main.log.info(self.name+": Clean") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 70 | elif i==2: |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 71 | main.log.error(self.name+": Connection terminated") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 72 | elif i==3: #timeout |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 73 | main.log.error(self.name+": Something while cleaning MN took too long... " ) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 74 | |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 75 | main.log.info(self.name+": building fresh mininet") |
admin | beea003 | 2014-01-23 14:54:13 -0800 | [diff] [blame] | 76 | #### for reactive/PARP enabled tests |
shahshreya | f4d4d0c | 2014-10-10 12:11:10 -0700 | [diff] [blame] | 77 | cmdString = "sudo mn " + self.options['arg1'] + " " + self.options['arg2'] + " --mac --controller " + self.options['controller'] + " " + self.options['arg3'] |
Jon Hall | 1ccf82c | 2014-10-15 14:55:16 -0400 | [diff] [blame] | 78 | |
| 79 | argList = self.options['arg1'].split(",") |
| 80 | global topoArgList |
| 81 | topoArgList = argList[0].split(" ") |
| 82 | argList = map(int, argList[1:]) |
| 83 | topoArgList = topoArgList[1:] + argList |
| 84 | |
| 85 | #### for proactive flow with static ARP entries |
shahshreya | f4d4d0c | 2014-10-10 12:11:10 -0700 | [diff] [blame] | 86 | #cmdString = "sudo mn " + self.options['arg1'] + " " + self.options['arg2'] + " --mac --arp --controller " + self.options['controller'] + " " + self.options['arg3'] |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 87 | self.handle.sendline(cmdString) |
Jon Hall | 333fa8c | 2014-04-11 11:24:58 -0700 | [diff] [blame] | 88 | self.handle.expect(["sudo mn",pexpect.EOF,pexpect.TIMEOUT]) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 89 | while 1: |
| 90 | i=self.handle.expect(['mininet>','\*\*\*','Exception',pexpect.EOF,pexpect.TIMEOUT],300) |
| 91 | if i==0: |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 92 | main.log.info(self.name+": mininet built") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 93 | return main.TRUE |
| 94 | if i==1: |
Jon Hall | 333fa8c | 2014-04-11 11:24:58 -0700 | [diff] [blame] | 95 | self.handle.expect(["\n",pexpect.EOF,pexpect.TIMEOUT]) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 96 | main.log.info(self.handle.before) |
| 97 | elif i==2: |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 98 | main.log.error(self.name+": Launching mininet failed...") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 99 | return main.FALSE |
| 100 | elif i==3: |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 101 | main.log.error(self.name+": Connection timeout") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 102 | return main.FALSE |
| 103 | elif i==4: #timeout |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 104 | main.log.error(self.name+": Something took too long... " ) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 105 | return main.FALSE |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 106 | #if utilities.assert_matches(expect=patterns,actual=resultCommand,onpass="Network is being launched",onfail="Network launching is being failed "): |
| 107 | return main.TRUE |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 108 | else:#if no handle |
| 109 | main.log.error(self.name+": Connection failed to the host "+self.user_name+"@"+self.ip_address) |
| 110 | main.log.error(self.name+": Failed to connect to the Mininet") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 111 | return main.FALSE |
Jon Hall | 1ccf82c | 2014-10-15 14:55:16 -0400 | [diff] [blame] | 112 | |
| 113 | def num_switches_n_links(self,topoType,depth,fanout): |
| 114 | if topoType == 'tree': |
| 115 | if fanout is None: #In tree topology, if fanout arg is not given, by default it is 2 |
| 116 | fanout = 2 |
| 117 | k = 0 |
| 118 | sum = 0 |
| 119 | while(k <= depth-1): |
| 120 | sum = sum + pow(fanout,k) |
| 121 | k = k+1 |
| 122 | num_switches = sum |
| 123 | while(k <= depth-2): |
| 124 | '''depth-2 gives you only core links and not considering edge links as seen by ONOS |
| 125 | If all the links including edge links are required, do depth-1 |
| 126 | ''' |
| 127 | sum = sum + pow(fanout,k) |
| 128 | k = k+1 |
| 129 | num_links = sum * fanout |
| 130 | #print "num_switches for %s(%d,%d) = %d and links=%d" %(topoType,depth,fanout,num_switches,num_links) |
| 131 | |
| 132 | elif topoType =='linear': |
| 133 | if fanout is None: #In linear topology, if fanout or num_hosts_per_sw is not given, by default it is 1 |
| 134 | fanout = 1 |
| 135 | num_switches = depth |
| 136 | num_hosts_per_sw = fanout |
| 137 | total_num_hosts = num_switches * num_hosts_per_sw |
| 138 | num_links = total_num_hosts + (num_switches - 1) |
| 139 | print "num_switches for %s(%d,%d) = %d and links=%d" %(topoType,depth,fanout,num_switches,num_links) |
| 140 | topoDict = {} |
| 141 | topoDict = {"num_switches":int(num_switches), "num_corelinks":int(num_links)} |
| 142 | return topoDict |
| 143 | |
| 144 | |
| 145 | def calculate_sw_and_links(self): |
| 146 | topoDict = self.num_switches_n_links(*topoArgList) |
| 147 | return topoDict |
| 148 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 149 | def pingall(self): |
| 150 | ''' |
Jon Hall | 41f40e8 | 2014-04-08 16:43:17 -0700 | [diff] [blame] | 151 | Verifies the reachability of the hosts using pingall command. |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 152 | ''' |
| 153 | if self.handle : |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 154 | main.log.info(self.name+": Checking reachabilty to the hosts using pingall") |
Jon Hall | 6094a36 | 2014-04-11 14:46:56 -0700 | [diff] [blame] | 155 | try: |
Jon Hall | efa4fa1 | 2014-04-14 11:40:21 -0700 | [diff] [blame] | 156 | response = self.execute(cmd="pingall",prompt="mininet>",timeout=120) |
Jon Hall | 77f53ce | 2014-10-13 18:02:06 -0400 | [diff] [blame] | 157 | print "response: " + str(response) |
Jon Hall | 6094a36 | 2014-04-11 14:46:56 -0700 | [diff] [blame] | 158 | except pexpect.EOF: |
| 159 | main.log.error(self.name + ": EOF exception found") |
| 160 | main.log.error(self.name + ": " + self.handle.before) |
| 161 | main.cleanup() |
| 162 | main.exit() |
Jon Hall | f4c8d01 | 2014-10-09 19:35:08 -0400 | [diff] [blame] | 163 | pattern = 'Results\:\s0\%\sdropped\s' |
andrew@onlab.us | 59e8f69 | 2014-10-09 21:41:48 -0400 | [diff] [blame] | 164 | #FIXME:Pending Mininet Pull Request #408 |
Jon Hall | f4c8d01 | 2014-10-09 19:35:08 -0400 | [diff] [blame] | 165 | #pattern = 'Results\:\s0\.00\%\sdropped\s' |
| 166 | print response |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 167 | #if utilities.assert_matches(expect=pattern,actual=response,onpass="All hosts are reaching",onfail="Unable to reach all the hosts"): |
| 168 | if re.search(pattern,response): |
| 169 | main.log.info(self.name+": All hosts are reachable") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 170 | return main.TRUE |
| 171 | else: |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 172 | main.log.error(self.name+": Unable to reach all the hosts") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 173 | return main.FALSE |
| 174 | else : |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 175 | main.log.error(self.name+": Connection failed to the host") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 176 | return main.FALSE |
admin | aeedddd | 2013-08-02 15:14:15 -0700 | [diff] [blame] | 177 | |
| 178 | def fpingHost(self,**pingParams): |
| 179 | ''' |
| 180 | Uses the fping package for faster pinging... |
| 181 | *requires fping to be installed on machine running mininet |
| 182 | ''' |
| 183 | args = utilities.parse_args(["SRC","TARGET"],**pingParams) |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 184 | command = args["SRC"] + " fping -i 100 -t 20 -C 1 -q "+args["TARGET"] |
admin | aeedddd | 2013-08-02 15:14:15 -0700 | [diff] [blame] | 185 | self.handle.sendline(command) |
Jon Hall | 333fa8c | 2014-04-11 11:24:58 -0700 | [diff] [blame] | 186 | self.handle.expect([args["TARGET"],pexpect.EOF,pexpect.TIMEOUT]) |
| 187 | self.handle.expect(["mininet",pexpect.EOF,pexpect.TIMEOUT]) |
admin | aeedddd | 2013-08-02 15:14:15 -0700 | [diff] [blame] | 188 | response = self.handle.before |
| 189 | if re.search(":\s-" ,response): |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 190 | main.log.info(self.name+": Ping fail") |
admin | aeedddd | 2013-08-02 15:14:15 -0700 | [diff] [blame] | 191 | return main.FALSE |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 192 | elif re.search(":\s\d{1,2}\.\d\d", response): |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 193 | main.log.info(self.name+": Ping good!") |
admin | aeedddd | 2013-08-02 15:14:15 -0700 | [diff] [blame] | 194 | return main.TRUE |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 195 | main.log.info(self.name+": Install fping on mininet machine... ") |
| 196 | main.log.info(self.name+": \n---\n"+response) |
admin | aeedddd | 2013-08-02 15:14:15 -0700 | [diff] [blame] | 197 | return main.FALSE |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 198 | |
| 199 | def pingHost(self,**pingParams): |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 200 | ''' |
| 201 | Ping from one mininet host to another |
| 202 | Currently the only supported Params: SRC and TARGET |
| 203 | ''' |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 204 | args = utilities.parse_args(["SRC","TARGET"],**pingParams) |
| 205 | #command = args["SRC"] + " ping -" + args["CONTROLLER"] + " " +args ["TARGET"] |
Jon Hall | 0819fd9 | 2014-05-23 12:08:13 -0700 | [diff] [blame] | 206 | command = args["SRC"] + " ping "+args ["TARGET"]+" -c 1 -i 1 -W 8" |
Jon Hall | 6094a36 | 2014-04-11 14:46:56 -0700 | [diff] [blame] | 207 | try: |
Jon Hall | 6e18c7b | 2014-04-23 16:26:33 -0700 | [diff] [blame] | 208 | main.log.warn("Sending: " + command) |
| 209 | #response = self.execute(cmd=command,prompt="mininet",timeout=10 ) |
| 210 | self.handle.sendline(command) |
| 211 | i = self.handle.expect([command,pexpect.TIMEOUT]) |
| 212 | if i == 1: |
| 213 | main.log.error(self.name + ": timeout when waiting for response from mininet") |
| 214 | main.log.error("response: " + str(self.handle.before)) |
| 215 | i = self.handle.expect(["mininet>",pexpect.TIMEOUT]) |
| 216 | if i == 1: |
| 217 | main.log.error(self.name + ": timeout when waiting for response from mininet") |
| 218 | main.log.error("response: " + str(self.handle.before)) |
| 219 | response = self.handle.before |
Jon Hall | 6094a36 | 2014-04-11 14:46:56 -0700 | [diff] [blame] | 220 | except pexpect.EOF: |
| 221 | main.log.error(self.name + ": EOF exception found") |
| 222 | main.log.error(self.name + ": " + self.handle.before) |
| 223 | main.cleanup() |
| 224 | main.exit() |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 225 | main.log.info(self.name+": Ping Response: "+ response ) |
| 226 | #if utilities.assert_matches(expect=',\s0\%\spacket\sloss',actual=response,onpass="No Packet loss",onfail="Host is not reachable"): |
| 227 | if re.search(',\s0\%\spacket\sloss',response): |
Jon Hall | 6e18c7b | 2014-04-23 16:26:33 -0700 | [diff] [blame] | 228 | main.log.info(self.name+": no packets lost, host is reachable") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 229 | main.last_result = main.TRUE |
| 230 | return main.TRUE |
| 231 | else : |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 232 | main.log.error(self.name+": PACKET LOST, HOST IS NOT REACHABLE") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 233 | main.last_result = main.FALSE |
| 234 | return main.FALSE |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 235 | |
| 236 | def checkIP(self,host): |
| 237 | ''' |
Jon Hall | 41f40e8 | 2014-04-08 16:43:17 -0700 | [diff] [blame] | 238 | Verifies the host's ip configured or not. |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 239 | ''' |
| 240 | if self.handle : |
Jon Hall | 6094a36 | 2014-04-11 14:46:56 -0700 | [diff] [blame] | 241 | try: |
| 242 | response = self.execute(cmd=host+" ifconfig",prompt="mininet>",timeout=10) |
| 243 | except pexpect.EOF: |
| 244 | main.log.error(self.name + ": EOF exception found") |
| 245 | main.log.error(self.name + ": " + self.handle.before) |
| 246 | main.cleanup() |
| 247 | main.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 248 | |
| 249 | pattern = "inet\s(addr|Mask):([0-1]{1}[0-9]{1,2}|2[0-4][0-9]|25[0-5]|[0-9]{1,2}).([0-1]{1}[0-9]{1,2}|2[0-4][0-9]|25[0-5]|[0-9]{1,2}).([0-1]{1}[0-9]{1,2}|2[0-4][0-9]|25[0-5]|[0-9]{1,2}).([0-1]{1}[0-9]{1,2}|2[0-4][0-9]|25[0-5]|[0-9]{1,2})" |
admin | 2a9548d | 2014-06-17 14:08:07 -0700 | [diff] [blame] | 250 | #pattern = "inet addr:10.0.0.6" |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 251 | #if utilities.assert_matches(expect=pattern,actual=response,onpass="Host Ip configured properly",onfail="Host IP not found") : |
| 252 | if re.search(pattern,response): |
| 253 | main.log.info(self.name+": Host Ip configured properly") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 254 | return main.TRUE |
| 255 | else: |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 256 | main.log.error(self.name+": Host IP not found") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 257 | return main.FALSE |
| 258 | else : |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 259 | main.log.error(self.name+": Connection failed to the host") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 260 | |
| 261 | def verifySSH(self,**connectargs): |
Jon Hall | 6094a36 | 2014-04-11 14:46:56 -0700 | [diff] [blame] | 262 | try: |
| 263 | response = self.execute(cmd="h1 /usr/sbin/sshd -D&",prompt="mininet>",timeout=10) |
| 264 | response = self.execute(cmd="h4 /usr/sbin/sshd -D&",prompt="mininet>",timeout=10) |
| 265 | for key in connectargs: |
| 266 | vars(self)[key] = connectargs[key] |
| 267 | response = self.execute(cmd="xterm h1 h4 ",prompt="mininet>",timeout=10) |
| 268 | except pexpect.EOF: |
| 269 | main.log.error(self.name + ": EOF exception found") |
| 270 | main.log.error(self.name + ": " + self.handle.before) |
| 271 | main.cleanup() |
| 272 | main.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 273 | import time |
| 274 | time.sleep(20) |
| 275 | if self.flag == 0: |
| 276 | self.flag = 1 |
| 277 | return main.FALSE |
| 278 | else : |
| 279 | return main.TRUE |
| 280 | |
| 281 | def getMacAddress(self,host): |
| 282 | ''' |
Jon Hall | 41f40e8 | 2014-04-08 16:43:17 -0700 | [diff] [blame] | 283 | Verifies the host's ip configured or not. |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 284 | ''' |
| 285 | if self.handle : |
Jon Hall | 6094a36 | 2014-04-11 14:46:56 -0700 | [diff] [blame] | 286 | try: |
| 287 | response = self.execute(cmd=host+" ifconfig",prompt="mininet>",timeout=10) |
| 288 | except pexpect.EOF: |
| 289 | main.log.error(self.name + ": EOF exception found") |
| 290 | main.log.error(self.name + ": " + self.handle.before) |
| 291 | main.cleanup() |
| 292 | main.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 293 | |
Ahmed El-Hassany | f720e20 | 2014-04-04 16:11:36 -0700 | [diff] [blame] | 294 | pattern = r'HWaddr\s([0-9A-F]{2}[:-]){5}([0-9A-F]{2})' |
| 295 | mac_address_search = re.search(pattern, response, re.I) |
| 296 | mac_address = mac_address_search.group().split(" ")[1] |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 297 | main.log.info(self.name+": Mac-Address of Host "+ host + " is " + mac_address) |
Ahmed El-Hassany | f720e20 | 2014-04-04 16:11:36 -0700 | [diff] [blame] | 298 | return mac_address |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 299 | else : |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 300 | main.log.error(self.name+": Connection failed to the host") |
Ahmed El-Hassany | fd32918 | 2014-04-10 11:38:16 -0700 | [diff] [blame] | 301 | |
| 302 | def getInterfaceMACAddress(self,host, interface): |
| 303 | ''' |
| 304 | Return the IP address of the interface on the given host |
| 305 | ''' |
| 306 | if self.handle : |
Jon Hall | 6094a36 | 2014-04-11 14:46:56 -0700 | [diff] [blame] | 307 | try: |
| 308 | response = self.execute(cmd=host+" ifconfig " + interface, |
Ahmed El-Hassany | fd32918 | 2014-04-10 11:38:16 -0700 | [diff] [blame] | 309 | prompt="mininet>",timeout=10) |
Jon Hall | 6094a36 | 2014-04-11 14:46:56 -0700 | [diff] [blame] | 310 | except pexpect.EOF: |
| 311 | main.log.error(self.name + ": EOF exception found") |
| 312 | main.log.error(self.name + ": " + self.handle.before) |
| 313 | main.cleanup() |
| 314 | main.exit() |
Ahmed El-Hassany | fd32918 | 2014-04-10 11:38:16 -0700 | [diff] [blame] | 315 | |
| 316 | pattern = r'HWaddr\s([0-9A-F]{2}[:-]){5}([0-9A-F]{2})' |
| 317 | mac_address_search = re.search(pattern, response, re.I) |
| 318 | if mac_address_search is None: |
| 319 | main.log.info("No mac address found in %s" % response) |
| 320 | return main.FALSE |
| 321 | mac_address = mac_address_search.group().split(" ")[1] |
| 322 | main.log.info("Mac-Address of "+ host + ":"+ interface + " is " + mac_address) |
| 323 | return mac_address |
| 324 | else: |
| 325 | main.log.error("Connection failed to the host") |
| 326 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 327 | def getIPAddress(self,host): |
| 328 | ''' |
Jon Hall | 41f40e8 | 2014-04-08 16:43:17 -0700 | [diff] [blame] | 329 | Verifies the host's ip configured or not. |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 330 | ''' |
| 331 | if self.handle : |
Jon Hall | 6094a36 | 2014-04-11 14:46:56 -0700 | [diff] [blame] | 332 | try: |
| 333 | response = self.execute(cmd=host+" ifconfig",prompt="mininet>",timeout=10) |
| 334 | except pexpect.EOF: |
| 335 | main.log.error(self.name + ": EOF exception found") |
| 336 | main.log.error(self.name + ": " + self.handle.before) |
| 337 | main.cleanup() |
| 338 | main.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 339 | |
| 340 | pattern = "inet\saddr:(\d+\.\d+\.\d+\.\d+)" |
| 341 | ip_address_search = re.search(pattern, response) |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 342 | main.log.info(self.name+": IP-Address of Host "+host +" is "+ip_address_search.group(1)) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 343 | return ip_address_search.group(1) |
| 344 | else : |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 345 | main.log.error(self.name+": Connection failed to the host") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 346 | |
Ahmed El-Hassany | fd32918 | 2014-04-10 11:38:16 -0700 | [diff] [blame] | 347 | def getSwitchDPID(self,switch): |
| 348 | ''' |
| 349 | return the datapath ID of the switch |
| 350 | ''' |
| 351 | if self.handle : |
| 352 | cmd = "py %s.dpid" % switch |
Jon Hall | 6094a36 | 2014-04-11 14:46:56 -0700 | [diff] [blame] | 353 | try: |
| 354 | response = self.execute(cmd=cmd,prompt="mininet>",timeout=10) |
| 355 | except pexpect.EOF: |
| 356 | main.log.error(self.name + ": EOF exception found") |
| 357 | main.log.error(self.name + ": " + self.handle.before) |
| 358 | main.cleanup() |
| 359 | main.exit() |
Ahmed El-Hassany | fd32918 | 2014-04-10 11:38:16 -0700 | [diff] [blame] | 360 | pattern = r'^(?P<dpid>\d)+' |
| 361 | result = re.search(pattern, response, re.MULTILINE) |
| 362 | if result is None: |
| 363 | main.log.info("Couldn't find DPID for switch '', found: %s" % (switch, response)) |
| 364 | return main.FALSE |
Jon Hall | c1a1d24 | 2014-07-21 16:03:33 -0700 | [diff] [blame] | 365 | return str(result.group(0)) |
Ahmed El-Hassany | fd32918 | 2014-04-10 11:38:16 -0700 | [diff] [blame] | 366 | else: |
| 367 | main.log.error("Connection failed to the host") |
| 368 | |
admin | 2580a0e | 2014-07-29 11:24:34 -0700 | [diff] [blame] | 369 | def getDPID(self, switch): |
| 370 | if self.handle: |
| 371 | self.handle.sendline("") |
| 372 | self.expect("mininet>") |
| 373 | cmd = "py %s.dpid" %switch |
| 374 | try: |
| 375 | response = self.execute(cmd=cmd,prompt="mininet>",timeout=10) |
| 376 | self.handle.expect("mininet>") |
| 377 | response = self.handle.before |
| 378 | return response |
| 379 | except pexpect.EOF: |
| 380 | main.log.error(self.name + ": EOF exception found") |
| 381 | main.log.error(self.name + ": " + self.handle.before) |
| 382 | main.cleanup() |
| 383 | main.exit() |
| 384 | |
| 385 | |
Ahmed El-Hassany | fd32918 | 2014-04-10 11:38:16 -0700 | [diff] [blame] | 386 | def getInterfaces(self, node): |
| 387 | ''' |
| 388 | return information dict about interfaces connected to the node |
| 389 | ''' |
| 390 | if self.handle : |
| 391 | cmd = 'py "\\n".join(["name=%s,mac=%s,ip=%s,isUp=%s" % (i.name, i.MAC(), i.IP(), i.isUp())' |
| 392 | cmd += ' for i in %s.intfs.values()])' % node |
Jon Hall | 6094a36 | 2014-04-11 14:46:56 -0700 | [diff] [blame] | 393 | try: |
| 394 | response = self.execute(cmd=cmd,prompt="mininet>",timeout=10) |
| 395 | except pexpect.EOF: |
| 396 | main.log.error(self.name + ": EOF exception found") |
| 397 | main.log.error(self.name + ": " + self.handle.before) |
| 398 | main.cleanup() |
| 399 | main.exit() |
Ahmed El-Hassany | fd32918 | 2014-04-10 11:38:16 -0700 | [diff] [blame] | 400 | return response |
| 401 | else: |
| 402 | main.log.error("Connection failed to the node") |
| 403 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 404 | def dump(self): |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 405 | main.log.info(self.name+": Dump node info") |
Jon Hall | 6094a36 | 2014-04-11 14:46:56 -0700 | [diff] [blame] | 406 | try: |
| 407 | response = self.execute(cmd = 'dump',prompt = 'mininet>',timeout = 10) |
| 408 | except pexpect.EOF: |
| 409 | main.log.error(self.name + ": EOF exception found") |
| 410 | main.log.error(self.name + ": " + self.handle.before) |
| 411 | main.cleanup() |
| 412 | main.exit() |
Ahmed El-Hassany | d1f7170 | 2014-04-04 16:12:45 -0700 | [diff] [blame] | 413 | return response |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 414 | |
| 415 | def intfs(self): |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 416 | main.log.info(self.name+": List interfaces") |
Jon Hall | 6094a36 | 2014-04-11 14:46:56 -0700 | [diff] [blame] | 417 | try: |
| 418 | response = self.execute(cmd = 'intfs',prompt = 'mininet>',timeout = 10) |
| 419 | except pexpect.EOF: |
| 420 | main.log.error(self.name + ": EOF exception found") |
| 421 | main.log.error(self.name + ": " + self.handle.before) |
| 422 | main.cleanup() |
| 423 | main.exit() |
Jon Hall | 668ed80 | 2014-04-08 17:17:59 -0700 | [diff] [blame] | 424 | return response |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 425 | |
| 426 | def net(self): |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 427 | main.log.info(self.name+": List network connections") |
Jon Hall | 6094a36 | 2014-04-11 14:46:56 -0700 | [diff] [blame] | 428 | try: |
| 429 | response = self.execute(cmd = 'net',prompt = 'mininet>',timeout = 10) |
| 430 | except pexpect.EOF: |
| 431 | main.log.error(self.name + ": EOF exception found") |
| 432 | main.log.error(self.name + ": " + self.handle.before) |
| 433 | main.cleanup() |
| 434 | main.exit() |
Jon Hall | 668ed80 | 2014-04-08 17:17:59 -0700 | [diff] [blame] | 435 | return response |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 436 | |
| 437 | def iperf(self): |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 438 | main.log.info(self.name+": Simple iperf TCP test between two (optionally specified) hosts") |
Jon Hall | 6094a36 | 2014-04-11 14:46:56 -0700 | [diff] [blame] | 439 | try: |
| 440 | response = self.execute(cmd = 'iperf',prompt = 'mininet>',timeout = 10) |
| 441 | except pexpect.EOF: |
| 442 | main.log.error(self.name + ": EOF exception found") |
| 443 | main.log.error(self.name + ": " + self.handle.before) |
| 444 | main.cleanup() |
| 445 | main.exit() |
Jon Hall | 668ed80 | 2014-04-08 17:17:59 -0700 | [diff] [blame] | 446 | return response |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 447 | |
| 448 | def iperfudp(self): |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 449 | main.log.info(self.name+": Simple iperf TCP test between two (optionally specified) hosts") |
Jon Hall | 6094a36 | 2014-04-11 14:46:56 -0700 | [diff] [blame] | 450 | try: |
| 451 | response = self.execute(cmd = 'iperfudp',prompt = 'mininet>',timeout = 10) |
| 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 | 668ed80 | 2014-04-08 17:17:59 -0700 | [diff] [blame] | 457 | return response |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 458 | |
| 459 | def nodes(self): |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 460 | main.log.info(self.name+": List all nodes.") |
Jon Hall | 6094a36 | 2014-04-11 14:46:56 -0700 | [diff] [blame] | 461 | try: |
| 462 | response = self.execute(cmd = 'nodes',prompt = 'mininet>',timeout = 10) |
| 463 | except pexpect.EOF: |
| 464 | main.log.error(self.name + ": EOF exception found") |
| 465 | main.log.error(self.name + ": " + self.handle.before) |
| 466 | main.cleanup() |
| 467 | main.exit() |
Jon Hall | 668ed80 | 2014-04-08 17:17:59 -0700 | [diff] [blame] | 468 | return response |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 469 | |
| 470 | def pingpair(self): |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 471 | main.log.info(self.name+": Ping between first two hosts") |
Jon Hall | 6094a36 | 2014-04-11 14:46:56 -0700 | [diff] [blame] | 472 | try: |
| 473 | response = self.execute(cmd = 'pingpair',prompt = 'mininet>',timeout = 20) |
| 474 | except pexpect.EOF: |
| 475 | main.log.error(self.name + ": EOF exception found") |
| 476 | main.log.error(self.name + ": " + self.handle.before) |
| 477 | main.cleanup() |
| 478 | main.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 479 | |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 480 | #if utilities.assert_matches(expect='0% packet loss',actual=response,onpass="No Packet loss",onfail="Hosts not reachable"): |
| 481 | if re.search(',\s0\%\spacket\sloss',response): |
| 482 | main.log.info(self.name+": Ping between two hosts SUCCESSFUL") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 483 | main.last_result = main.TRUE |
| 484 | return main.TRUE |
| 485 | else : |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 486 | main.log.error(self.name+": PACKET LOST, HOSTS NOT REACHABLE") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 487 | main.last_result = main.FALSE |
| 488 | return main.FALSE |
| 489 | |
| 490 | def link(self,**linkargs): |
| 491 | ''' |
| 492 | Bring link(s) between two nodes up or down |
| 493 | ''' |
| 494 | main.log.info('Bring link(s) between two nodes up or down') |
| 495 | args = utilities.parse_args(["END1","END2","OPTION"],**linkargs) |
| 496 | end1 = args["END1"] if args["END1"] != None else "" |
| 497 | end2 = args["END2"] if args["END2"] != None else "" |
| 498 | option = args["OPTION"] if args["OPTION"] != None else "" |
| 499 | command = "link "+str(end1) + " " + str(end2)+ " " + str(option) |
Jon Hall | 6094a36 | 2014-04-11 14:46:56 -0700 | [diff] [blame] | 500 | try: |
Jon Hall | e80ef8c | 2014-04-29 15:29:13 -0700 | [diff] [blame] | 501 | #response = self.execute(cmd=command,prompt="mininet>",timeout=10) |
| 502 | self.handle.sendline(command) |
| 503 | self.handle.expect("mininet>") |
Jon Hall | 6094a36 | 2014-04-11 14:46:56 -0700 | [diff] [blame] | 504 | except pexpect.EOF: |
| 505 | main.log.error(self.name + ": EOF exception found") |
| 506 | main.log.error(self.name + ": " + self.handle.before) |
| 507 | main.cleanup() |
| 508 | main.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 509 | return main.TRUE |
| 510 | |
| 511 | |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 512 | def yank(self,**yankargs): |
admin | aeedddd | 2013-08-02 15:14:15 -0700 | [diff] [blame] | 513 | ''' |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 514 | yank a mininet switch interface to a host |
admin | aeedddd | 2013-08-02 15:14:15 -0700 | [diff] [blame] | 515 | ''' |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 516 | main.log.info('Yank the switch interface attached to a host') |
| 517 | args = utilities.parse_args(["SW","INTF"],**yankargs) |
admin | aeedddd | 2013-08-02 15:14:15 -0700 | [diff] [blame] | 518 | sw = args["SW"] if args["SW"] !=None else "" |
| 519 | intf = args["INTF"] if args["INTF"] != None else "" |
| 520 | command = "py "+ str(sw) + '.detach("' + str(intf) + '")' |
Jon Hall | 6094a36 | 2014-04-11 14:46:56 -0700 | [diff] [blame] | 521 | try: |
| 522 | response = self.execute(cmd=command,prompt="mininet>",timeout=10) |
| 523 | except pexpect.EOF: |
| 524 | main.log.error(self.name + ": EOF exception found") |
| 525 | main.log.error(self.name + ": " + self.handle.before) |
| 526 | main.cleanup() |
| 527 | main.exit() |
admin | aeedddd | 2013-08-02 15:14:15 -0700 | [diff] [blame] | 528 | return main.TRUE |
| 529 | |
| 530 | def plug(self, **plugargs): |
| 531 | ''' |
| 532 | plug the yanked mininet switch interface to a switch |
| 533 | ''' |
| 534 | main.log.info('Plug the switch interface attached to a switch') |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 535 | args = utilities.parse_args(["SW","INTF"],**plugargs) |
admin | aeedddd | 2013-08-02 15:14:15 -0700 | [diff] [blame] | 536 | sw = args["SW"] if args["SW"] !=None else "" |
| 537 | intf = args["INTF"] if args["INTF"] != None else "" |
| 538 | command = "py "+ str(sw) + '.attach("' + str(intf) + '")' |
Jon Hall | 6094a36 | 2014-04-11 14:46:56 -0700 | [diff] [blame] | 539 | try: |
| 540 | response = self.execute(cmd=command,prompt="mininet>",timeout=10) |
| 541 | except pexpect.EOF: |
| 542 | main.log.error(self.name + ": EOF exception found") |
| 543 | main.log.error(self.name + ": " + self.handle.before) |
| 544 | main.cleanup() |
| 545 | main.exit() |
admin | aeedddd | 2013-08-02 15:14:15 -0700 | [diff] [blame] | 546 | return main.TRUE |
| 547 | |
| 548 | |
| 549 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 550 | def dpctl(self,**dpctlargs): |
| 551 | ''' |
Jon Hall | 41f40e8 | 2014-04-08 16:43:17 -0700 | [diff] [blame] | 552 | Run dpctl command on all switches. |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 553 | ''' |
| 554 | main.log.info('Run dpctl command on all switches') |
| 555 | args = utilities.parse_args(["CMD","ARGS"],**dpctlargs) |
| 556 | cmd = args["CMD"] if args["CMD"] != None else "" |
| 557 | cmdargs = args["ARGS"] if args["ARGS"] != None else "" |
| 558 | command = "dpctl "+cmd + " " + str(cmdargs) |
Jon Hall | 6094a36 | 2014-04-11 14:46:56 -0700 | [diff] [blame] | 559 | try: |
| 560 | response = self.execute(cmd=command,prompt="mininet>",timeout=10) |
| 561 | except pexpect.EOF: |
| 562 | main.log.error(self.name + ": EOF exception found") |
| 563 | main.log.error(self.name + ": " + self.handle.before) |
| 564 | main.cleanup() |
| 565 | main.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 566 | return main.TRUE |
| 567 | |
| 568 | |
| 569 | def get_version(self): |
| 570 | file_input = path+'/lib/Mininet/INSTALL' |
| 571 | version = super(Mininet, self).get_version() |
| 572 | pattern = 'Mininet\s\w\.\w\.\w\w*' |
| 573 | for line in open(file_input,'r').readlines(): |
| 574 | result = re.match(pattern, line) |
| 575 | if result: |
| 576 | version = result.group(0) |
| 577 | return version |
| 578 | |
admin | 2a9548d | 2014-06-17 14:08:07 -0700 | [diff] [blame] | 579 | def get_sw_controller_sanity(self, sw): |
| 580 | command = "sh ovs-vsctl get-controller "+str(sw) |
| 581 | try: |
| 582 | response = self.execute(cmd=command,prompt="mininet>",timeout=10) |
| 583 | if response: |
| 584 | return main.TRUE |
| 585 | else: |
| 586 | return main.FALSE |
| 587 | except pexpect.EOF: |
| 588 | main.log.error(self.name + ": EOF exception found") |
| 589 | main.log.error(self.name + ": " + self.handle.before) |
| 590 | main.cleanup() |
| 591 | main.exit() |
| 592 | else: |
| 593 | main.log.info(response) |
| 594 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 595 | def get_sw_controller(self,sw): |
| 596 | command = "sh ovs-vsctl get-controller "+str(sw) |
Jon Hall | 6094a36 | 2014-04-11 14:46:56 -0700 | [diff] [blame] | 597 | try: |
| 598 | response = self.execute(cmd=command,prompt="mininet>",timeout=10) |
admin | 2a9548d | 2014-06-17 14:08:07 -0700 | [diff] [blame] | 599 | print(response) |
| 600 | if response: |
admin | dc1c507 | 2014-06-24 15:57:19 -0700 | [diff] [blame] | 601 | print("**********************") |
admin | 2a9548d | 2014-06-17 14:08:07 -0700 | [diff] [blame] | 602 | return response |
| 603 | else: |
| 604 | return main.FALSE |
Jon Hall | 6094a36 | 2014-04-11 14:46:56 -0700 | [diff] [blame] | 605 | except pexpect.EOF: |
| 606 | main.log.error(self.name + ": EOF exception found") |
| 607 | main.log.error(self.name + ": " + self.handle.before) |
| 608 | main.cleanup() |
| 609 | main.exit() |
| 610 | else: |
| 611 | main.log.info(response) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 612 | |
| 613 | def assign_sw_controller(self,**kwargs): |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 614 | ''' |
| 615 | count is only needed if there is more than 1 controller |
| 616 | ''' |
| 617 | args = utilities.parse_args(["COUNT"],**kwargs) |
| 618 | count = args["COUNT"] if args!={} else 1 |
| 619 | |
| 620 | argstring = "SW" |
| 621 | for j in range(count): |
| 622 | argstring = argstring + ",IP" + str(j+1) + ",PORT" + str(j+1) |
| 623 | args = utilities.parse_args(argstring.split(","),**kwargs) |
| 624 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 625 | sw = args["SW"] if args["SW"] != None else "" |
admin | 530b4c9 | 2013-08-14 16:54:35 -0700 | [diff] [blame] | 626 | ptcpA = int(args["PORT1"])+int(sw) if args["PORT1"] != None else "" |
Jon Hall | f89c855 | 2014-04-02 13:14:06 -0700 | [diff] [blame] | 627 | ptcpB = "ptcp:"+str(ptcpA) if ptcpA != "" else "" |
| 628 | |
| 629 | command = "sh ovs-vsctl set-controller s" + str(sw) + " " + ptcpB + " " |
| 630 | for j in range(count): |
| 631 | i=j+1 |
| 632 | args = utilities.parse_args(["IP"+str(i),"PORT"+str(i)],**kwargs) |
| 633 | ip = args["IP"+str(i)] if args["IP"+str(i)] != None else "" |
| 634 | port = args["PORT" + str(i)] if args["PORT" + str(i)] != None else "" |
| 635 | tcp = "tcp:" + str(ip) + ":" + str(port) + " " if ip != "" else "" |
| 636 | command = command + tcp |
Jon Hall | 6094a36 | 2014-04-11 14:46:56 -0700 | [diff] [blame] | 637 | try: |
| 638 | self.execute(cmd=command,prompt="mininet>",timeout=5) |
| 639 | except pexpect.EOF: |
| 640 | main.log.error(self.name + ": EOF exception found") |
| 641 | main.log.error(self.name + ": " + self.handle.before) |
| 642 | main.cleanup() |
| 643 | main.exit() |
| 644 | except: |
| 645 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 646 | main.log.error( traceback.print_exc() ) |
| 647 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 648 | main.cleanup() |
| 649 | main.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 650 | |
Jon Hall | 0819fd9 | 2014-05-23 12:08:13 -0700 | [diff] [blame] | 651 | def delete_sw_controller(self,sw): |
| 652 | ''' |
| 653 | Removes the controller target from sw |
| 654 | ''' |
| 655 | |
| 656 | command = "sh ovs-vsctl del-controller "+str(sw) |
| 657 | try: |
| 658 | response = self.execute(cmd=command,prompt="mininet>",timeout=10) |
| 659 | except pexpect.EOF: |
| 660 | main.log.error(self.name + ": EOF exception found") |
| 661 | main.log.error(self.name + ": " + self.handle.before) |
| 662 | main.cleanup() |
| 663 | main.exit() |
| 664 | else: |
| 665 | main.log.info(response) |
| 666 | |
| 667 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 668 | def disconnect(self): |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 669 | main.log.info(self.name+": Disconnecting mininet...") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 670 | response = '' |
| 671 | if self.handle: |
Jon Hall | 6094a36 | 2014-04-11 14:46:56 -0700 | [diff] [blame] | 672 | try: |
| 673 | response = self.execute(cmd="exit",prompt="(.*)",timeout=120) |
| 674 | response = self.execute(cmd="exit",prompt="(.*)",timeout=120) |
Jon Hall | e80ef8c | 2014-04-29 15:29:13 -0700 | [diff] [blame] | 675 | self.handle.sendline("sudo mn -c") |
Jon Hall | 6094a36 | 2014-04-11 14:46:56 -0700 | [diff] [blame] | 676 | except pexpect.EOF: |
| 677 | main.log.error(self.name + ": EOF exception found") |
| 678 | main.log.error(self.name + ": " + self.handle.before) |
| 679 | main.cleanup() |
| 680 | main.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 681 | else : |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 682 | main.log.error(self.name+": Connection failed to the host") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 683 | response = main.FALSE |
| 684 | return response |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 685 | |
| 686 | def arping(self, src, dest, destmac): |
| 687 | self.handle.sendline('') |
Jon Hall | 333fa8c | 2014-04-11 11:24:58 -0700 | [diff] [blame] | 688 | self.handle.expect(["mininet",pexpect.EOF,pexpect.TIMEOUT]) |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 689 | |
| 690 | self.handle.sendline(src + ' arping ' + dest) |
| 691 | try: |
Jon Hall | 333fa8c | 2014-04-11 11:24:58 -0700 | [diff] [blame] | 692 | self.handle.expect([destmac,pexpect.EOF,pexpect.TIMEOUT]) |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 693 | main.log.info(self.name+": ARP successful") |
Jon Hall | 333fa8c | 2014-04-11 11:24:58 -0700 | [diff] [blame] | 694 | self.handle.expect(["mininet",pexpect.EOF,pexpect.TIMEOUT]) |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 695 | return main.TRUE |
| 696 | except: |
Jon Hall | f2942ce | 2014-04-10 16:00:16 -0700 | [diff] [blame] | 697 | main.log.warn(self.name+": ARP FAILURE") |
Jon Hall | 333fa8c | 2014-04-11 11:24:58 -0700 | [diff] [blame] | 698 | self.handle.expect(["mininet",pexpect.EOF,pexpect.TIMEOUT]) |
admin | 0752993 | 2013-11-22 14:58:28 -0800 | [diff] [blame] | 699 | return main.FALSE |
| 700 | |
| 701 | def decToHex(num): |
| 702 | return hex(num).split('x')[1] |
admin | 2a9548d | 2014-06-17 14:08:07 -0700 | [diff] [blame] | 703 | |
| 704 | def getSwitchFlowCount(self, switch): |
| 705 | ''' |
| 706 | return the Flow Count of the switch |
| 707 | ''' |
| 708 | if self.handle: |
| 709 | cmd = "sh ovs-ofctl dump-aggregate %s" % switch |
| 710 | try: |
| 711 | response = self.execute(cmd=cmd, prompt="mininet>", timeout=10) |
| 712 | except pexpect.EOF: |
| 713 | main.log.error(self.name + ": EOF exception found") |
| 714 | main.log.error(self.name + " " + self.handle.before) |
| 715 | main.cleanup() |
| 716 | main.exit() |
| 717 | pattern = "flow_count=(\d+)" |
| 718 | result = re.search(pattern, response, re.MULTILINE) |
| 719 | if result is None: |
| 720 | print "no flow on switch print test" |
| 721 | main.log.info("Couldn't find flows on switch '', found: %s" % (switch, response)) |
| 722 | return main.FALSE |
| 723 | return result.group(1) |
| 724 | else: |
| 725 | main.log.error("Connection failed to the Mininet host") |
| 726 | |
Ahmed El-Hassany | b6545eb | 2014-08-01 11:32:10 -0700 | [diff] [blame] | 727 | def check_flows(self, sw, dump_format=None): |
| 728 | if dump_format: |
| 729 | command = "sh ovs-ofctl -F " + dump_format + " dump-flows " + str(sw) |
| 730 | else: |
| 731 | command = "sh ovs-ofctl dump-flows "+str(sw) |
admin | 2a9548d | 2014-06-17 14:08:07 -0700 | [diff] [blame] | 732 | try: |
| 733 | response=self.execute(cmd=command,prompt="mininet>",timeout=10) |
| 734 | return response |
| 735 | except pexpect.EOF: |
| 736 | main.log.error(self.name + ": EOF exception found") |
| 737 | main.log.error(self.name + ": " + self.handle.before) |
| 738 | main.cleanup() |
| 739 | main.exit() |
| 740 | else: |
| 741 | main.log.info(response) |
| 742 | |
| 743 | def start_tcpdump(self, filename, intf = "eth0", port = "port 6633"): |
| 744 | ''' |
| 745 | Runs tpdump on an intferface and saves the file |
| 746 | intf can be specified, or the default eth0 is used |
| 747 | ''' |
| 748 | try: |
| 749 | self.handle.sendline("") |
| 750 | self.handle.expect("mininet>") |
| 751 | self.handle.sendline("sh sudo tcpdump -n -i "+ intf + " " + port + " -w " + filename.strip() + " &") |
| 752 | self.handle.sendline("") |
| 753 | self.handle.sendline("") |
| 754 | i=self.handle.expect(['No\ssuch\device','listening\son',pexpect.TIMEOUT,"mininet>"],timeout=10) |
| 755 | main.log.warn(self.handle.before + self.handle.after) |
| 756 | if i == 0: |
| 757 | main.log.error(self.name + ": tcpdump - No such device exists. tcpdump attempted on: " + intf) |
| 758 | return main.FALSE |
| 759 | elif i == 1: |
| 760 | main.log.info(self.name + ": tcpdump started on " + intf) |
| 761 | return main.TRUE |
| 762 | elif i == 2: |
| 763 | main.log.error(self.name + ": tcpdump command timed out! Check interface name, given interface was: " + intf) |
| 764 | return main.FALSE |
| 765 | elif i ==3: |
| 766 | main.log.info(self.name +": " + self.handle.before) |
| 767 | return main.TRUE |
| 768 | else: |
| 769 | main.log.error(self.name + ": tcpdump - unexpected response") |
| 770 | return main.FALSE |
| 771 | except pexpect.EOF: |
| 772 | main.log.error(self.name + ": EOF exception found") |
| 773 | main.log.error(self.name + ": " + self.handle.before) |
| 774 | main.cleanup() |
| 775 | main.exit() |
| 776 | except: |
| 777 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 778 | main.log.error( traceback.print_exc() ) |
| 779 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 780 | main.cleanup() |
| 781 | main.exit() |
| 782 | |
| 783 | def stop_tcpdump(self): |
| 784 | "pkills tcpdump" |
| 785 | try: |
| 786 | self.handle.sendline("sh sudo pkill tcpdump") |
| 787 | self.handle.sendline("") |
| 788 | self.handle.sendline("") |
| 789 | self.handle.expect("mininet>") |
| 790 | except pexpect.EOF: |
| 791 | main.log.error(self.name + ": EOF exception found") |
| 792 | main.log.error(self.name + ": " + self.handle.before) |
| 793 | main.cleanup() |
| 794 | main.exit() |
| 795 | except: |
| 796 | main.log.info(self.name + ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 797 | main.log.error( traceback.print_exc() ) |
| 798 | main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::") |
| 799 | main.cleanup() |
| 800 | main.exit() |
| 801 | |
Jon Hall | 7c3d109 | 2014-08-11 15:08:31 -0700 | [diff] [blame] | 802 | def compare_topo(self, topo, onos_json): |
Jon Hall | 8412ed1 | 2014-07-24 16:33:58 -0700 | [diff] [blame] | 803 | ''' |
| 804 | compares mn topology with ONOS topology |
| 805 | onos_list is a list of ONOS controllers, each element of the list should be (handle, name, ip, port) |
| 806 | onos_json is the output of the onos get_json function calling the /wm/onos/topology REST API |
Jon Hall | e3a7450 | 2014-07-25 11:13:16 -0700 | [diff] [blame] | 807 | Returns: True if MN and ONOS topology match and False if the differ. |
| 808 | Differences between ONOS and MN topology will be printed to the log. |
| 809 | |
| 810 | Dependency: Requires STS to be installed on the TestON machine. STS can be pulled |
| 811 | from https://github.com/ucb-sts/sts.git . Currently the required functions from STS are located in the |
| 812 | topology_refactoring2 branch, but may be merged into the master branch soon. You may need to install some |
| 813 | python modules such as networkx to use the STS functions. |
| 814 | |
Jon Hall | 38f5012 | 2014-08-05 13:16:52 -0700 | [diff] [blame] | 815 | To install sts: |
| 816 | $ git clone git://github.com/ucb-sts/sts.git |
| 817 | $ cd sts |
| 818 | $ git clone -b debugger git://github.com/ucb-sts/pox.git |
| 819 | $ sudo apt-get install python-dev |
| 820 | $ ./tools/install_hassel_python.sh |
| 821 | $ sudo pip install networkx |
| 822 | |
| 823 | Include sts in your PYTHONPATH. it should looks comething like: |
| 824 | PYTHONPATH=/home/admin/TestON:/home/admin/sts |
| 825 | |
Jon Hall | 8412ed1 | 2014-07-24 16:33:58 -0700 | [diff] [blame] | 826 | ''' |
admin | 680b78c | 2014-08-08 11:46:45 -0700 | [diff] [blame] | 827 | import sys |
| 828 | sys.path.append("~/sts") |
Jon Hall | e934133 | 2014-08-07 10:09:36 -0700 | [diff] [blame] | 829 | #NOTE: Create this once per Test and pass the TestONTopology object around. It takes too long to create this object. |
| 830 | # This will make it easier to use the sts methods for severing links and solve that issue |
Jon Hall | 0d88a25 | 2014-07-25 11:22:40 -0700 | [diff] [blame] | 831 | import json |
admin | 2a9548d | 2014-06-17 14:08:07 -0700 | [diff] [blame] | 832 | |
Jon Hall | 8412ed1 | 2014-07-24 16:33:58 -0700 | [diff] [blame] | 833 | link_results = main.TRUE |
| 834 | switch_results = main.TRUE |
| 835 | port_results = main.TRUE |
| 836 | |
| 837 | ########Switches####### |
| 838 | output = {"switches":[]} |
Jon Hall | 0d88a25 | 2014-07-25 11:22:40 -0700 | [diff] [blame] | 839 | for switch in topo.graph.switches: #iterate through the MN topology and pull out switches and and port info |
Jon Hall | 8412ed1 | 2014-07-24 16:33:58 -0700 | [diff] [blame] | 840 | ports = [] |
| 841 | for port in switch.ports.values(): |
Jon Hall | 38f5012 | 2014-08-05 13:16:52 -0700 | [diff] [blame] | 842 | #print port.hw_addr.toStr(separator = '') |
| 843 | ports.append({'of_port': port.port_no, 'mac': str(port.hw_addr).replace('\'',''), 'name': port.name}) |
| 844 | output['switches'].append({"name": switch.name, "dpid": str(switch.dpid).zfill(16), "ports": ports }) |
Jon Hall | 8412ed1 | 2014-07-24 16:33:58 -0700 | [diff] [blame] | 845 | #print output |
| 846 | |
Jon Hall | 8412ed1 | 2014-07-24 16:33:58 -0700 | [diff] [blame] | 847 | #print json.dumps(output, sort_keys=True,indent=4,separators=(',', ': ')) |
| 848 | |
| 849 | |
Jon Hall | 0d88a25 | 2014-07-25 11:22:40 -0700 | [diff] [blame] | 850 | # created sorted list of dpid's in MN and ONOS for comparison |
Jon Hall | 8412ed1 | 2014-07-24 16:33:58 -0700 | [diff] [blame] | 851 | mnDPIDs=[] |
| 852 | for switch in output['switches']: |
| 853 | mnDPIDs.append(switch['dpid']) |
| 854 | mnDPIDs.sort() |
Jon Hall | e934133 | 2014-08-07 10:09:36 -0700 | [diff] [blame] | 855 | #print mnDPIDs |
Jon Hall | 0d88a25 | 2014-07-25 11:22:40 -0700 | [diff] [blame] | 856 | if onos_json == "":#if rest call fails |
Jon Hall | 8412ed1 | 2014-07-24 16:33:58 -0700 | [diff] [blame] | 857 | main.log.error(self.name + ".compare_topo(): Empty JSON object given from ONOS rest call") |
| 858 | return main.FALSE |
| 859 | onos=onos_json |
| 860 | onosDPIDs=[] |
| 861 | for switch in onos['switches']: |
| 862 | onosDPIDs.append(switch['dpid'].replace(":",'')) |
| 863 | onosDPIDs.sort() |
Jon Hall | e934133 | 2014-08-07 10:09:36 -0700 | [diff] [blame] | 864 | #print onosDPIDs |
Jon Hall | 8412ed1 | 2014-07-24 16:33:58 -0700 | [diff] [blame] | 865 | |
| 866 | if mnDPIDs!=onosDPIDs: |
| 867 | switch_results = main.FALSE |
| 868 | main.log.report( "Switches in MN but not in ONOS:") |
| 869 | main.log.report( str([switch for switch in mnDPIDs if switch not in onosDPIDs])) |
| 870 | main.log.report( "Switches in ONOS but not in MN:") |
| 871 | main.log.report( str([switch for switch in onosDPIDs if switch not in mnDPIDs])) |
| 872 | else:#list of dpid's match in onos and mn |
| 873 | switch_results = main.TRUE |
| 874 | |
| 875 | ################ports############# |
| 876 | for switch in output['switches']: |
| 877 | mn_ports = [] |
| 878 | onos_ports = [] |
| 879 | for port in switch['ports']: |
| 880 | mn_ports.append(port['of_port']) |
| 881 | for onos_switch in onos['switches']: |
| 882 | if onos_switch['dpid'].replace(':','') == switch['dpid']: |
| 883 | for port in onos_switch['ports']: |
| 884 | onos_ports.append(port['portNumber']) |
| 885 | mn_ports.sort() |
| 886 | onos_ports.sort() |
shahshreya | f4d4d0c | 2014-10-10 12:11:10 -0700 | [diff] [blame] | 887 | #print "mn_ports[] = ", mn_ports |
| 888 | #print "onos_ports90 = ", onos_ports |
| 889 | |
| 890 | #if mn_ports == onos_ports: |
| 891 | #pass #don't set results to true here as this is just one of many checks and it might override a failure |
| 892 | |
| 893 | #For OF1.3, the OFP_local port number is 0xfffffffe or 4294967294 instead of 0xfffe or 65534 in OF1.0, ONOS topology |
| 894 | #sees the correct port number, however MN topolofy as read from line 151 of https://github.com/ucb-sts/sts/blob/ |
| 895 | #topology_refactoring2/sts/entities/teston_entities.py is 0xfffe which doesn't work correctly with OF1.3 switches. |
| 896 | #So a short term fix is to ignore the case when mn_port == 65534 and onos_port ==4294967294. |
| 897 | for mn_port,onos_port in zip(mn_ports,onos_ports): |
| 898 | if mn_port == onos_port or (mn_port == 65534 and onos_port ==4294967294): |
| 899 | continue |
| 900 | else: |
| 901 | port_results = main.FALSE |
| 902 | break |
Jon Hall | 8412ed1 | 2014-07-24 16:33:58 -0700 | [diff] [blame] | 903 | pass #don't set results to true here as this is just one of many checks and it might override a failure |
shahshreya | f4d4d0c | 2014-10-10 12:11:10 -0700 | [diff] [blame] | 904 | ''' |
Jon Hall | 8412ed1 | 2014-07-24 16:33:58 -0700 | [diff] [blame] | 905 | else: #the ports of this switch don't match |
| 906 | port_results = main.FALSE |
| 907 | main.log.report("ports in MN switch %s(%s) but not in ONOS:" % (switch['name'],switch['dpid'])) |
| 908 | main.log.report( str([port for port in mn_ports if port not in onos_ports])) |
| 909 | main.log.report("ports in ONOS switch %s(%s) but not in MN:" % (switch['name'],switch['dpid'])) |
| 910 | main.log.report( str([port for port in onos_ports if port not in mn_ports])) |
shahshreya | f4d4d0c | 2014-10-10 12:11:10 -0700 | [diff] [blame] | 911 | ''' |
| 912 | if port_results == main.FALSE: |
| 913 | main.log.report("ports in MN switch %s(%s) but not in ONOS:" % (switch['name'],switch['dpid'])) |
| 914 | main.log.report( str([port for port in mn_ports if port not in onos_ports])) |
| 915 | main.log.report("ports in ONOS switch %s(%s) but not in MN:" % (switch['name'],switch['dpid'])) |
| 916 | main.log.report( str([port for port in onos_ports if port not in mn_ports])) |
Jon Hall | 8412ed1 | 2014-07-24 16:33:58 -0700 | [diff] [blame] | 917 | |
| 918 | #######Links######## |
Jon Hall | 0d88a25 | 2014-07-25 11:22:40 -0700 | [diff] [blame] | 919 | # iterate through MN links and check if and ONOS link exists in both directions |
Jon Hall | e934133 | 2014-08-07 10:09:36 -0700 | [diff] [blame] | 920 | # NOTE: Will currently only show mn links as down if they are cut through STS. |
| 921 | # We can either do everything through STS or wait for up_network_links |
| 922 | # and down_network_links to be fully implemented. |
Jon Hall | 8412ed1 | 2014-07-24 16:33:58 -0700 | [diff] [blame] | 923 | for link in topo.patch_panel.network_links: |
| 924 | #print "Link: %s" % link |
| 925 | #TODO: Find a more efficient search method |
| 926 | node1 = None |
| 927 | port1 = None |
| 928 | node2 = None |
| 929 | port2 = None |
| 930 | first_dir = main.FALSE |
| 931 | second_dir = main.FALSE |
| 932 | for switch in output['switches']: |
| 933 | if switch['name'] == link.node1.name: |
| 934 | node1 = switch['dpid'] |
| 935 | for port in switch['ports']: |
| 936 | if str(port['name']) == str(link.port1): |
| 937 | port1 = port['of_port'] |
| 938 | if node1 is not None and node2 is not None: |
| 939 | break |
| 940 | if switch['name'] == link.node2.name: |
| 941 | node2 = switch['dpid'] |
| 942 | for port in switch['ports']: |
| 943 | if str(port['name']) == str(link.port2): |
| 944 | port2 = port['of_port'] |
| 945 | if node1 is not None and node2 is not None: |
| 946 | break |
| 947 | # check onos link from node1 to node2 |
| 948 | for onos_link in onos['links']: |
| 949 | if onos_link['src']['dpid'].replace(":",'') == node1 and onos_link['dst']['dpid'].replace(":",'') == node2: |
| 950 | if onos_link['src']['portNumber'] == port1 and onos_link['dst']['portNumber'] == port2: |
| 951 | first_dir = main.TRUE |
| 952 | else: |
| 953 | main.log.report('the port numbers do not match for ' +str(link) + ' between ONOS and MN') |
| 954 | #print node1, ' to ', node2 |
| 955 | elif onos_link['src']['dpid'].replace(":",'') == node2 and onos_link['dst']['dpid'].replace(":",'') == node1: |
| 956 | if onos_link['src']['portNumber'] == port2 and onos_link['dst']['portNumber'] == port1: |
| 957 | second_dir = main.TRUE |
| 958 | else: |
| 959 | main.log.report('the port numbers do not match for ' +str(link) + ' between ONOS and MN') |
| 960 | #print node2, ' to ', node1 |
| 961 | else:#this is not the link you're looking for |
| 962 | pass |
| 963 | if not first_dir: |
| 964 | main.log.report('ONOS has issues with the link from '+str(link.node1.name) +"(dpid: "+ str(node1)+"):"+str(link.port1)+"(portNumber: "+str(port1)+")"+ ' to ' + str(link.node2.name) +"(dpid: "+ str(node2)+"):"+str(link.port2)+"(portNumber: "+str(port2)+")") |
| 965 | if not second_dir: |
| 966 | main.log.report('ONOS has issues with the link from '+str(link.node2.name) +"(dpid: "+ str(node2)+"):"+str(link.port2)+"(portNumber: "+str(port2)+")"+ ' to ' + str(link.node1.name) +"(dpid: "+ str(node1)+"):"+str(link.port1)+"(portNumber: "+str(port1)+")") |
| 967 | link_results = link_results and first_dir and second_dir |
| 968 | |
| 969 | |
| 970 | results = switch_results and port_results and link_results |
Jon Hall | e934133 | 2014-08-07 10:09:36 -0700 | [diff] [blame] | 971 | # if not results: #To print out both topologies |
| 972 | # main.log.error("Topology comparison failed, printing json objects, MN then ONOS") |
| 973 | # main.log.error(str(json.dumps(output, sort_keys=True,indent=4,separators=(',', ': ')))) |
| 974 | # main.log.error('MN Links:') |
| 975 | # for link in topo.patch_panel.network_links: main.log.error(str("\tLink: %s" % link)) |
| 976 | # main.log.error(str(json.dumps(onos, sort_keys=True,indent=4,separators=(',', ': ')))) |
Jon Hall | 8412ed1 | 2014-07-24 16:33:58 -0700 | [diff] [blame] | 977 | return results |
admin | 2a9548d | 2014-06-17 14:08:07 -0700 | [diff] [blame] | 978 | |
| 979 | |
| 980 | |
| 981 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 982 | |
| 983 | if __name__ != "__main__": |
| 984 | import sys |
| 985 | sys.modules[__name__] = MininetCliDriver() |
admin | 2a9548d | 2014-06-17 14:08:07 -0700 | [diff] [blame] | 986 | |