kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1 | """ |
| 2 | Wrapper functions for FuncIntent |
| 3 | This functions include Onosclidriver and Mininetclidriver driver functions |
| 4 | Author: kelvin@onlab.us |
| 5 | """ |
| 6 | import time |
| 7 | import copy |
| 8 | import json |
| 9 | |
| 10 | def __init__( self ): |
| 11 | self.default = '' |
| 12 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 13 | def installHostIntent( main, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 14 | name, |
| 15 | host1, |
| 16 | host2, |
| 17 | onosNode=0, |
| 18 | ethType="", |
| 19 | bandwidth="", |
| 20 | lambdaAlloc=False, |
| 21 | ipProto="", |
| 22 | ipAddresses="", |
| 23 | tcp="", |
| 24 | sw1="", |
Jeremy Songster | ff55367 | 2016-05-12 17:06:23 -0700 | [diff] [blame] | 25 | sw2="", |
| 26 | setVlan="" ): |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 27 | """ |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 28 | Installs a Host Intent |
| 29 | |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 30 | Description: |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 31 | Install a host intent using |
| 32 | add-host-intent |
| 33 | |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 34 | Steps: |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 35 | - Fetch host data if not given |
| 36 | - Add host intent |
| 37 | - Ingress device is the first sender host |
| 38 | - Egress devices are the recipient devices |
| 39 | - Ports if defined in senders or recipients |
| 40 | - MAC address ethSrc loaded from Ingress device |
| 41 | - Check intent state with retry |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 42 | Required: |
| 43 | name - Type of point intent to add eg. IPV4 | VLAN | Dualstack |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 44 | host1 - Dictionary for host1 |
| 45 | { "name":"h8", "id":"of:0000000000000005/8" } |
| 46 | host2 - Dictionary for host2 |
| 47 | { "name":"h16", "id":"of:0000000000000006/8" } |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 48 | Optional: |
| 49 | onosNode - ONOS node to install the intents in main.CLIs[ ] |
| 50 | 0 by default so that it will always use the first |
| 51 | ONOS node |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 52 | ethType - Ethernet type eg. IPV4, IPV6 |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 53 | bandwidth - Bandwidth capacity |
| 54 | lambdaAlloc - Allocate lambda, defaults to False |
| 55 | ipProto - IP protocol |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 56 | tcp - TCP ports in the same order as the hosts in hostNames |
| 57 | """ |
| 58 | |
| 59 | assert main, "There is no main variable" |
| 60 | assert host1, "You must specify host1" |
| 61 | assert host2, "You must specify host2" |
| 62 | |
| 63 | global itemName # The name of this run. Used for logs. |
| 64 | itemName = name |
| 65 | onosNode = int( onosNode ) |
| 66 | |
| 67 | main.log.info( itemName + ": Adding single point to multi point intents" ) |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 68 | try: |
| 69 | if not host1.get( "id" ): |
| 70 | main.log.warn( "ID not given for host1 {0}. Loading from main.hostData".format( host1.get( "name" ) ) ) |
| 71 | main.log.debug( main.hostsData.get( host1.get( "name" ) ) ) |
| 72 | host1[ "id" ] = main.hostsData.get( host1.get( "name" ) ).get( "id" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 73 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 74 | if not host2.get( "id" ): |
| 75 | main.log.warn( "ID not given for host2 {0}. Loading from main.hostData".format( host2.get( "name" ) ) ) |
| 76 | host2[ "id" ] = main.hostsData.get( host2.get( "name" ) ).get( "id" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 77 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 78 | # Adding point intent |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 79 | vlanId = host1.get( "vlan" ) |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 80 | intentId = main.CLIs[ onosNode ].addHostIntent( hostIdOne=host1.get( "id" ), |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 81 | hostIdTwo=host2.get( "id" ), |
Jeremy Songster | ff55367 | 2016-05-12 17:06:23 -0700 | [diff] [blame] | 82 | vlanId=vlanId, |
| 83 | setVlan=setVlan ) |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 84 | except (KeyError, TypeError): |
| 85 | errorMsg = "There was a problem loading the hosts data." |
| 86 | if intentId: |
| 87 | errorMsg += " There was a problem installing host to host intent." |
| 88 | main.log.error( errorMsg ) |
| 89 | return main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 90 | |
| 91 | # Check intents state |
| 92 | if utilities.retry( f=checkIntentState, retValue=main.FALSE, |
| 93 | args=( main, [ intentId ] ), sleep=main.checkIntentSleep ): |
| 94 | return intentId |
| 95 | else: |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 96 | main.log.error( "Host Intent did not install correctly" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 97 | return main.FALSE |
| 98 | |
| 99 | def testHostIntent( main, |
| 100 | name, |
| 101 | intentId, |
| 102 | host1, |
| 103 | host2, |
| 104 | onosNode=0, |
| 105 | sw1="s5", |
| 106 | sw2="s2", |
| 107 | expectedLink=0): |
| 108 | """ |
| 109 | Test a Host Intent |
| 110 | |
| 111 | Description: |
| 112 | Test a host intent of given ID between given hosts |
| 113 | |
| 114 | Steps: |
| 115 | - Fetch host data if not given |
| 116 | - Check Intent State |
| 117 | - Check Flow State |
| 118 | - Check Connectivity |
| 119 | - Check Lack of Connectivity Between Hosts not in the Intent |
| 120 | - Reroute |
| 121 | - Take Expected Link Down |
| 122 | - Check Intent State |
| 123 | - Check Flow State |
| 124 | - Check Topology |
| 125 | - Check Connectivity |
| 126 | - Bring Expected Link Up |
| 127 | - Check Intent State |
| 128 | - Check Flow State |
| 129 | - Check Topology |
| 130 | - Check Connectivity |
| 131 | - Remove Topology |
| 132 | |
| 133 | Required: |
| 134 | name - Type of point intent to add eg. IPV4 | VLAN | Dualstack |
| 135 | intentId - intent ID to be tested ( and removed ) |
| 136 | host1 - Dictionary for host1 |
| 137 | { "name":"h8", "id":"of:0000000000000005/8" } |
| 138 | host2 - Dictionary for host2 |
| 139 | { "name":"h16", "id":"of:0000000000000006/8" } |
| 140 | Optional: |
| 141 | onosNode - ONOS node to install the intents in main.CLIs[ ] |
| 142 | 0 by default so that it will always use the first |
| 143 | ONOS node |
| 144 | sw1 - First switch to bring down & up for rerouting purpose |
| 145 | sw2 - Second switch to bring down & up for rerouting purpose |
| 146 | expectedLink - Expected link when the switches are down, it should |
| 147 | be two links lower than the links before the two |
| 148 | switches are down |
| 149 | |
| 150 | """ |
| 151 | |
| 152 | # Parameter Validity Check |
| 153 | assert main, "There is no main variable" |
| 154 | assert host1, "You must specify host1" |
| 155 | assert host2, "You must specify host2" |
| 156 | |
| 157 | global itemName |
| 158 | itemName = name |
| 159 | tempHostsData = {} |
| 160 | onosNode = int( onosNode ) |
| 161 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 162 | main.log.info( itemName + ": Testing Host Intent" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 163 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 164 | try: |
| 165 | if not host1.get( "id" ): |
| 166 | main.log.warn( "Id not given for host1 {0}. Loading from main.hostData".format( host1.get( "name" ) ) ) |
| 167 | host1[ "id" ] = main.hostsData.get( host1.get( "name" ) ).get( "location" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 168 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 169 | if not host2.get( "id" ): |
| 170 | main.log.warn( "Id not given for host2 {0}. Loading from main.hostData".format( host2.get( "name" ) ) ) |
| 171 | host2[ "id" ] = main.hostsData.get( host2.get( "name" ) ).get( "location" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 172 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 173 | senderNames = [ host1.get( "name" ), host2.get( "name" ) ] |
| 174 | recipientNames = [ host1.get( "name" ), host2.get( "name" ) ] |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 175 | vlanId = host1.get( "vlan" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 176 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 177 | testResult = main.TRUE |
| 178 | except (KeyError, TypeError): |
| 179 | main.log.error( "There was a problem loading the hosts data." ) |
| 180 | return main.FALSE |
| 181 | |
| 182 | main.log.info( itemName + ": Testing Host to Host intents" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 183 | |
| 184 | # Check intent state |
| 185 | if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [ intentId ] ), sleep=main.checkIntentSleep ): |
| 186 | main.assertReturnString += 'Initial Intent State Passed\n' |
| 187 | else: |
| 188 | main.assertReturnString += 'Initial Intent State Failed\n' |
| 189 | testResult = main.FALSE |
| 190 | |
| 191 | # Check flows count in each node |
Jeremy | 03dab01 | 2016-04-11 08:59:17 -0700 | [diff] [blame] | 192 | if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ) and utilities.retry( f=checkFlowsState, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 193 | main.assertReturnString += 'Initial Flow State Passed\n' |
| 194 | else: |
| 195 | main.assertReturnString += 'Intial Flow State Failed\n' |
| 196 | testResult = main.FALSE |
| 197 | |
| 198 | # Check Connectivity |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 199 | if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId ) ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 200 | main.assertReturnString += 'Initial Ping Passed\n' |
| 201 | else: |
| 202 | main.assertReturnString += 'Initial Ping Failed\n' |
| 203 | testResult = main.FALSE |
| 204 | |
| 205 | # Test rerouting if these variables exist |
| 206 | if sw1 and sw2 and expectedLink: |
| 207 | # Take link down |
| 208 | if utilities.retry( f=link, retValue=main.FALSE, args=( main, sw1, sw2, "down" ) ): |
| 209 | main.assertReturnString += 'Link Down Passed\n' |
| 210 | else: |
| 211 | main.assertReturnString += 'Link Down Failed\n' |
| 212 | testResult = main.FALSE |
| 213 | |
| 214 | # Check intent state |
| 215 | if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [ intentId ] ), sleep=main.checkIntentSleep ): |
| 216 | main.assertReturnString += 'Link Down Intent State Passed\n' |
| 217 | else: |
| 218 | main.assertReturnString += 'Link Down Intent State Failed\n' |
| 219 | testResult = main.FALSE |
| 220 | |
| 221 | # Check flows count in each node |
Jeremy | 03dab01 | 2016-04-11 08:59:17 -0700 | [diff] [blame] | 222 | if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ) and utilities.retry( f=checkFlowsState, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 223 | main.assertReturnString += 'Link Down Flow State Passed\n' |
| 224 | else: |
| 225 | main.assertReturnString += 'Link Down Flow State Failed\n' |
| 226 | testResult = main.FALSE |
| 227 | |
| 228 | # Check OnosTopology |
| 229 | if utilities.retry( f=checkTopology, retValue=main.FALSE, args=( main, expectedLink ) ): |
| 230 | main.assertReturnString += 'Link Down Topology State Passed\n' |
| 231 | else: |
| 232 | main.assertReturnString += 'Link Down Topology State Failed\n' |
| 233 | testResult = main.FALSE |
| 234 | |
| 235 | # Check Connection |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 236 | if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId ) ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 237 | main.assertReturnString += 'Link Down Pingall Passed\n' |
| 238 | else: |
| 239 | main.assertReturnString += 'Link Down Pingall Failed\n' |
| 240 | testResult = main.FALSE |
| 241 | |
| 242 | # Bring link up |
| 243 | if utilities.retry( f=link, retValue=main.FALSE, args=( main, sw1, sw2, "up" ) ): |
| 244 | main.assertReturnString += 'Link Up Passed\n' |
| 245 | else: |
| 246 | main.assertReturnString += 'Link Up Failed\n' |
| 247 | testResult = main.FALSE |
| 248 | |
| 249 | # Wait for reroute |
| 250 | time.sleep( main.rerouteSleep ) |
| 251 | |
| 252 | # Check Intents |
| 253 | if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [ intentId ] ), sleep=main.checkIntentSleep ): |
| 254 | main.assertReturnString += 'Link Up Intent State Passed\n' |
| 255 | else: |
| 256 | main.assertReturnString += 'Link Up Intent State Failed\n' |
| 257 | testResult = main.FALSE |
| 258 | |
| 259 | # Check flows count in each node |
Jeremy | 03dab01 | 2016-04-11 08:59:17 -0700 | [diff] [blame] | 260 | if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ) and utilities.retry( f=checkFlowsState, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 261 | main.assertReturnString += 'Link Up Flow State Passed\n' |
| 262 | else: |
| 263 | main.assertReturnString += 'Link Up Flow State Failed\n' |
| 264 | testResult = main.FALSE |
| 265 | |
| 266 | # Check OnosTopology |
| 267 | if utilities.retry( f=checkTopology, retValue=main.FALSE, args=( main, main.numLinks ) ): |
| 268 | main.assertReturnString += 'Link Up Topology State Passed\n' |
| 269 | else: |
| 270 | main.assertReturnString += 'Link Up Topology State Failed\n' |
| 271 | testResult = main.FALSE |
| 272 | |
| 273 | # Check Connection |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 274 | if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId ) ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 275 | main.assertReturnString += 'Link Up Pingall Passed\n' |
| 276 | else: |
| 277 | main.assertReturnString += 'Link Up Pingall Failed\n' |
| 278 | testResult = main.FALSE |
| 279 | |
| 280 | # Remove all intents |
| 281 | if utilities.retry( f=removeAllIntents, retValue=main.FALSE, args=( main, [ intentId ] ) ): |
| 282 | main.assertReturnString += 'Remove Intents Passed' |
| 283 | else: |
| 284 | main.assertReturnString += 'Remove Intents Failed' |
| 285 | testResult = main.FALSE |
| 286 | |
| 287 | return testResult |
| 288 | |
| 289 | def installPointIntent( main, |
| 290 | name, |
| 291 | senders, |
| 292 | recipients, |
| 293 | onosNode=0, |
| 294 | ethType="", |
| 295 | bandwidth="", |
| 296 | lambdaAlloc=False, |
| 297 | ipProto="", |
| 298 | ipSrc="", |
| 299 | ipDst="", |
| 300 | tcpSrc="", |
Jeremy Songster | ff55367 | 2016-05-12 17:06:23 -0700 | [diff] [blame] | 301 | tcpDst="", |
| 302 | setVlan=""): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 303 | """ |
| 304 | Installs a Single to Single Point Intent |
| 305 | |
| 306 | Description: |
| 307 | Install a single to single point intent |
| 308 | |
| 309 | Steps: |
| 310 | - Fetch host data if not given |
| 311 | - Add point intent |
| 312 | - Ingress device is the first sender device |
| 313 | - Egress device is the first recipient device |
| 314 | - Ports if defined in senders or recipients |
| 315 | - MAC address ethSrc loaded from Ingress device |
| 316 | - Check intent state with retry |
| 317 | Required: |
| 318 | name - Type of point intent to add eg. IPV4 | VLAN | Dualstack |
| 319 | senders - List of host dictionaries i.e. |
| 320 | [ { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" } ] |
| 321 | recipients - List of host dictionaries i.e. |
| 322 | [ { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" } ] |
| 323 | Optional: |
| 324 | onosNode - ONOS node to install the intents in main.CLIs[ ] |
| 325 | 0 by default so that it will always use the first |
| 326 | ONOS node |
| 327 | ethType - Ethernet type eg. IPV4, IPV6 |
| 328 | bandwidth - Bandwidth capacity |
| 329 | lambdaAlloc - Allocate lambda, defaults to False |
| 330 | ipProto - IP protocol |
| 331 | tcp - TCP ports in the same order as the hosts in hostNames |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 332 | sw1 - First switch to bring down & up for rerouting purpose |
| 333 | sw2 - Second switch to bring down & up for rerouting purpose |
| 334 | expectedLink - Expected link when the switches are down, it should |
| 335 | be two links lower than the links before the two |
| 336 | switches are down |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 337 | """ |
| 338 | |
| 339 | assert main, "There is no main variable" |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 340 | assert senders, "You must specify a sender" |
| 341 | assert recipients, "You must specify a recipient" |
| 342 | # Assert devices or main.hostsData, "You must specify devices" |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 343 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 344 | global itemName # The name of this run. Used for logs. |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 345 | itemName = name |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 346 | onosNode = int( onosNode ) |
| 347 | |
Jeremy | 6f000c6 | 2016-02-25 17:02:28 -0800 | [diff] [blame] | 348 | main.log.info( itemName + ": Adding point to point intents" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 349 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 350 | try: |
| 351 | for sender in senders: |
| 352 | if not sender.get( "device" ): |
| 353 | main.log.warn( "Device not given for sender {0}. Loading from main.hostData".format( sender.get( "name" ) ) ) |
| 354 | sender[ "device" ] = main.hostsData.get( sender.get( "name" ) ).get( "location" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 355 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 356 | for recipient in recipients: |
| 357 | if not recipient.get( "device" ): |
| 358 | main.log.warn( "Device not given for recipient {0}. Loading from main.hostData".format( recipient.get( "name" ) ) ) |
| 359 | recipient[ "device" ] = main.hostsData.get( recipient.get( "name" ) ).get( "location" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 360 | |
| 361 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 362 | ingressDevice = senders[ 0 ].get( "device" ) |
| 363 | egressDevice = recipients[ 0 ].get( "device" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 364 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 365 | portIngress = senders[ 0 ].get( "port", "" ) |
| 366 | portEgress = recipients[ 0 ].get( "port", "" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 367 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 368 | dstMac = recipients[ 0 ].get( "mac" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 369 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 370 | ipSrc = senders[ 0 ].get( "ip" ) |
| 371 | ipDst = recipients[ 0 ].get( "ip" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 372 | |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 373 | vlanId = senders[ 0 ].get( "vlan" ) |
| 374 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 375 | # Adding point intent |
| 376 | intentId = main.CLIs[ onosNode ].addPointIntent( |
| 377 | ingressDevice=ingressDevice, |
| 378 | egressDevice=egressDevice, |
| 379 | portIngress=portIngress, |
| 380 | portEgress=portEgress, |
| 381 | ethType=ethType, |
| 382 | ethDst=dstMac, |
| 383 | bandwidth=bandwidth, |
| 384 | lambdaAlloc=lambdaAlloc, |
| 385 | ipProto=ipProto, |
| 386 | ipSrc=ipSrc, |
| 387 | ipDst=ipDst, |
| 388 | tcpSrc=tcpSrc, |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 389 | tcpDst=tcpDst, |
Jeremy Songster | ff55367 | 2016-05-12 17:06:23 -0700 | [diff] [blame] | 390 | vlanId=vlanId, |
| 391 | setVlan=setVlan ) |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 392 | except (KeyError, TypeError): |
| 393 | errorMsg = "There was a problem loading the hosts data." |
| 394 | if intentId: |
| 395 | errorMsg += " There was a problem installing Point to Point intent." |
| 396 | main.log.error( errorMsg ) |
| 397 | return main.FALSE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 398 | |
| 399 | # Check intents state |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 400 | if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [ intentId ] ), sleep=main.checkIntentSleep ): |
| 401 | return intentId |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 402 | else: |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 403 | main.log.error( "Point Intent did not install correctly" ) |
| 404 | return main.FALSE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 405 | |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 406 | def pointIntentTcp( main, |
| 407 | name, |
| 408 | host1, |
| 409 | host2, |
| 410 | onosNode=0, |
| 411 | deviceId1="", |
| 412 | deviceId2="", |
| 413 | port1="", |
| 414 | port2="", |
| 415 | ethType="", |
| 416 | mac1="", |
| 417 | mac2="", |
| 418 | bandwidth="", |
| 419 | lambdaAlloc=False, |
| 420 | ipProto="", |
| 421 | ip1="", |
| 422 | ip2="", |
| 423 | tcp1="", |
| 424 | tcp2="", |
| 425 | sw1="", |
| 426 | sw2="", |
| 427 | expectedLink=0 ): |
| 428 | |
| 429 | """ |
| 430 | Description: |
| 431 | Verify add-point-intent only for TCP |
| 432 | Steps: |
| 433 | - Get device ids | ports |
| 434 | - Add point intents |
| 435 | - Check intents |
| 436 | - Verify flows |
| 437 | - Ping hosts |
| 438 | - Reroute |
| 439 | - Link down |
| 440 | - Verify flows |
| 441 | - Check topology |
| 442 | - Ping hosts |
| 443 | - Link up |
| 444 | - Verify flows |
| 445 | - Check topology |
| 446 | - Ping hosts |
| 447 | - Remove intents |
| 448 | Required: |
| 449 | name - Type of point intent to add eg. IPV4 | VLAN | Dualstack |
| 450 | host1 - Name of first host |
| 451 | host2 - Name of second host |
| 452 | Optional: |
| 453 | onosNode - ONOS node to install the intents in main.CLIs[ ] |
| 454 | 0 by default so that it will always use the first |
| 455 | ONOS node |
| 456 | deviceId1 - ONOS device id of the first switch, the same as the |
| 457 | location of the first host eg. of:0000000000000001/1, |
| 458 | located at device 1 port 1 |
| 459 | deviceId2 - ONOS device id of the second switch |
| 460 | port1 - The port number where the first host is attached |
| 461 | port2 - The port number where the second host is attached |
| 462 | ethType - Ethernet type eg. IPV4, IPV6 |
| 463 | mac1 - Mac address of first host |
| 464 | mac2 - Mac address of the second host |
| 465 | bandwidth - Bandwidth capacity |
| 466 | lambdaAlloc - Allocate lambda, defaults to False |
| 467 | ipProto - IP protocol |
| 468 | ip1 - IP address of first host |
| 469 | ip2 - IP address of second host |
| 470 | tcp1 - TCP port of first host |
| 471 | tcp2 - TCP port of second host |
| 472 | sw1 - First switch to bring down & up for rerouting purpose |
| 473 | sw2 - Second switch to bring down & up for rerouting purpose |
| 474 | expectedLink - Expected link when the switches are down, it should |
| 475 | be two links lower than the links before the two |
| 476 | switches are down |
| 477 | """ |
| 478 | |
| 479 | assert main, "There is no main variable" |
| 480 | assert name, "variable name is empty" |
| 481 | assert host1 and host2, "You must specify hosts" |
| 482 | |
| 483 | global itemName |
| 484 | itemName = name |
| 485 | host1 = host1 |
| 486 | host2 = host2 |
| 487 | hostNames = [ host1, host2 ] |
| 488 | intentsId = [] |
| 489 | |
| 490 | iperfResult = main.TRUE |
| 491 | intentResult = main.TRUE |
| 492 | removeIntentResult = main.TRUE |
| 493 | flowResult = main.TRUE |
| 494 | topoResult = main.TRUE |
| 495 | linkDownResult = main.TRUE |
| 496 | linkUpResult = main.TRUE |
| 497 | onosNode = int( onosNode ) |
| 498 | |
| 499 | # Adding bidirectional point intents |
| 500 | main.log.info( itemName + ": Adding point intents" ) |
| 501 | intent1 = main.CLIs[ onosNode ].addPointIntent( ingressDevice=deviceId1, |
| 502 | egressDevice=deviceId2, |
| 503 | portIngress=port1, |
| 504 | portEgress=port2, |
| 505 | ethType=ethType, |
| 506 | ethSrc=mac1, |
| 507 | ethDst=mac2, |
| 508 | bandwidth=bandwidth, |
| 509 | lambdaAlloc=lambdaAlloc, |
| 510 | ipProto=ipProto, |
| 511 | ipSrc=ip1, |
| 512 | ipDst=ip2, |
| 513 | tcpSrc=tcp1, |
| 514 | tcpDst="" ) |
| 515 | |
| 516 | intent2 = main.CLIs[ onosNode ].addPointIntent( ingressDevice=deviceId2, |
| 517 | egressDevice=deviceId1, |
| 518 | portIngress=port2, |
| 519 | portEgress=port1, |
| 520 | ethType=ethType, |
| 521 | ethSrc=mac2, |
| 522 | ethDst=mac1, |
| 523 | bandwidth=bandwidth, |
| 524 | lambdaAlloc=lambdaAlloc, |
| 525 | ipProto=ipProto, |
| 526 | ipSrc=ip2, |
| 527 | ipDst=ip1, |
| 528 | tcpSrc=tcp2, |
| 529 | tcpDst="" ) |
| 530 | |
| 531 | intent3 = main.CLIs[ onosNode ].addPointIntent( ingressDevice=deviceId1, |
| 532 | egressDevice=deviceId2, |
| 533 | portIngress=port1, |
| 534 | portEgress=port2, |
| 535 | ethType=ethType, |
| 536 | ethSrc=mac1, |
| 537 | ethDst=mac2, |
| 538 | bandwidth=bandwidth, |
| 539 | lambdaAlloc=lambdaAlloc, |
| 540 | ipProto=ipProto, |
| 541 | ipSrc=ip1, |
| 542 | ipDst=ip2, |
| 543 | tcpSrc="", |
| 544 | tcpDst=tcp2 ) |
| 545 | |
| 546 | intent4 = main.CLIs[ onosNode ].addPointIntent( ingressDevice=deviceId2, |
| 547 | egressDevice=deviceId1, |
| 548 | portIngress=port2, |
| 549 | portEgress=port1, |
| 550 | ethType=ethType, |
| 551 | ethSrc=mac2, |
| 552 | ethDst=mac1, |
| 553 | bandwidth=bandwidth, |
| 554 | lambdaAlloc=lambdaAlloc, |
| 555 | ipProto=ipProto, |
| 556 | ipSrc=ip2, |
| 557 | ipDst=ip1, |
| 558 | tcpSrc="", |
| 559 | tcpDst=tcp1 ) |
| 560 | intentsId.append( intent1 ) |
| 561 | intentsId.append( intent2 ) |
| 562 | intentsId.append( intent3 ) |
| 563 | intentsId.append( intent4 ) |
| 564 | |
| 565 | # Check intents state |
| 566 | time.sleep( main.checkIntentSleep ) |
| 567 | intentResult = checkIntentState( main, intentsId ) |
| 568 | # Check flows count in each node |
| 569 | checkFlowsCount( main ) |
| 570 | |
| 571 | # Check intents state again if first check fails... |
| 572 | if not intentResult: |
| 573 | intentResult = checkIntentState( main, intentsId ) |
| 574 | |
| 575 | # Check flows count in each node |
| 576 | checkFlowsCount( main ) |
| 577 | |
| 578 | # Verify flows |
| 579 | checkFlowsState( main ) |
| 580 | |
| 581 | # Run iperf to both host |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 582 | iperfTemp = main.Mininet1.iperftcp( host1,host2,10 ) |
| 583 | iperfResult = iperfResult and iperfTemp |
| 584 | if iperfTemp: |
| 585 | main.assertReturnString += 'Initial Iperf Passed\n' |
| 586 | else: |
| 587 | main.assertReturnString += 'Initial Iperf Failed\n' |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 588 | |
| 589 | # Test rerouting if these variables exist |
| 590 | if sw1 and sw2 and expectedLink: |
| 591 | # link down |
| 592 | linkDownResult = link( main, sw1, sw2, "down" ) |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 593 | |
| 594 | if linkDownResult: |
| 595 | main.assertReturnString += 'Link Down Passed\n' |
| 596 | else: |
| 597 | main.assertReturnString += 'Link Down Failed\n' |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 598 | |
| 599 | # Check flows count in each node |
| 600 | checkFlowsCount( main ) |
| 601 | # Verify flows |
| 602 | checkFlowsState( main ) |
| 603 | |
| 604 | # Check OnosTopology |
| 605 | topoResult = checkTopology( main, expectedLink ) |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 606 | if topoResult: |
| 607 | main.assertReturnString += 'Link Down Topology State Passed\n' |
| 608 | else: |
| 609 | main.assertReturnString += 'Link Down Topology State Failed\n' |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 610 | |
| 611 | # Run iperf to both host |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 612 | iperfTemp = main.Mininet1.iperftcp( host1,host2,10 ) |
| 613 | iperfResult = iperfResult and iperfTemp |
| 614 | if iperfTemp: |
| 615 | main.assertReturnString += 'Link Down Iperf Passed\n' |
| 616 | else: |
| 617 | main.assertReturnString += 'Link Down Iperf Failed\n' |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 618 | |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 619 | # Check intent state |
| 620 | intentTemp = checkIntentState( main, intentsId ) |
| 621 | intentResult = intentResult and intentTemp |
| 622 | if intentTemp: |
| 623 | main.assertReturnString += 'Link Down Intent State Passed\n' |
| 624 | else: |
| 625 | main.assertReturnString += 'Link Down Intent State Failed\n' |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 626 | |
| 627 | # Checks ONOS state in link down |
| 628 | if linkDownResult and topoResult and iperfResult and intentResult: |
| 629 | main.log.info( itemName + ": Successfully brought link down" ) |
| 630 | else: |
| 631 | main.log.error( itemName + ": Failed to bring link down" ) |
| 632 | |
| 633 | # link up |
| 634 | linkUpResult = link( main, sw1, sw2, "up" ) |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 635 | if linkUpTemp: |
| 636 | main.assertReturnString += 'Link Up Passed\n' |
| 637 | else: |
| 638 | main.assertReturnString += 'Link Up Failed\n' |
| 639 | |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 640 | time.sleep( main.rerouteSleep ) |
| 641 | |
| 642 | # Check flows count in each node |
| 643 | checkFlowsCount( main ) |
| 644 | # Verify flows |
| 645 | checkFlowsState( main ) |
| 646 | |
| 647 | # Check OnosTopology |
| 648 | topoResult = checkTopology( main, main.numLinks ) |
| 649 | |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 650 | if topoResult: |
| 651 | main.assertReturnString += 'Link Up Topology State Passed\n' |
| 652 | else: |
| 653 | main.assertReturnString += 'Link Up Topology State Failed\n' |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 654 | |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 655 | # Run iperf to both host |
| 656 | iperfTemp = main.Mininet1.iperftcp( host1,host2,10 ) |
| 657 | iperfResult = iperfResult and iperfTemp |
| 658 | if iperfTemp: |
| 659 | main.assertReturnString += 'Link Up Iperf Passed\n' |
| 660 | else: |
| 661 | main.assertReturnString += 'Link Up Iperf Failed\n' |
| 662 | |
| 663 | # Check intent state |
| 664 | intentTemp = checkIntentState( main, intentsId ) |
| 665 | intentResult = intentResult and intentTemp |
| 666 | if intentTemp: |
| 667 | main.assertReturnString += 'Link Down Intent State Passed\n' |
| 668 | else: |
| 669 | main.assertReturnString += 'Link Down Intent State Failed\n' |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 670 | |
| 671 | # Checks ONOS state in link up |
| 672 | if linkUpResult and topoResult and iperfResult and intentResult: |
| 673 | main.log.info( itemName + ": Successfully brought link back up" ) |
| 674 | else: |
| 675 | main.log.error( itemName + ": Failed to bring link back up" ) |
| 676 | |
| 677 | # Remove all intents |
| 678 | removeIntentResult = removeAllIntents( main, intentsId ) |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 679 | if removeIntentResult: |
| 680 | main.assertReturnString += 'Remove Intents Passed' |
| 681 | else: |
| 682 | main.assertReturnString += 'Remove Intents Failed' |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 683 | |
| 684 | stepResult = iperfResult and linkDownResult and linkUpResult \ |
| 685 | and intentResult and removeIntentResult |
| 686 | |
| 687 | return stepResult |
| 688 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 689 | def installSingleToMultiIntent( main, |
| 690 | name, |
| 691 | senders, |
| 692 | recipients, |
| 693 | onosNode=0, |
| 694 | ethType="", |
| 695 | bandwidth="", |
| 696 | lambdaAlloc=False, |
| 697 | ipProto="", |
| 698 | ipAddresses="", |
| 699 | tcp="", |
| 700 | sw1="", |
Jeremy Songster | ff55367 | 2016-05-12 17:06:23 -0700 | [diff] [blame] | 701 | sw2="", |
| 702 | setVlan=""): |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 703 | """ |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 704 | Installs a Single to Multi Point Intent |
| 705 | |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 706 | Description: |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 707 | Install a single to multi point intent using |
| 708 | add-single-to-multi-intent |
| 709 | |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 710 | Steps: |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 711 | - Fetch host data if not given |
| 712 | - Add single to multi intent |
| 713 | - Ingress device is the first sender host |
| 714 | - Egress devices are the recipient devices |
| 715 | - Ports if defined in senders or recipients |
| 716 | - MAC address ethSrc loaded from Ingress device |
| 717 | - Check intent state with retry |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 718 | Required: |
| 719 | name - Type of point intent to add eg. IPV4 | VLAN | Dualstack |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 720 | senders - List of host dictionaries i.e. |
| 721 | { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" } |
| 722 | recipients - List of host dictionaries i.e. |
| 723 | { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" } |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 724 | Optional: |
| 725 | onosNode - ONOS node to install the intents in main.CLIs[ ] |
| 726 | 0 by default so that it will always use the first |
| 727 | ONOS node |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 728 | ethType - Ethernet type eg. IPV4, IPV6 |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 729 | bandwidth - Bandwidth capacity |
| 730 | lambdaAlloc - Allocate lambda, defaults to False |
| 731 | ipProto - IP protocol |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 732 | tcp - TCP ports in the same order as the hosts in hostNames |
| 733 | sw1 - First switch to bring down & up for rerouting purpose |
| 734 | sw2 - Second switch to bring down & up for rerouting purpose |
| 735 | expectedLink - Expected link when the switches are down, it should |
| 736 | be two links lower than the links before the two |
| 737 | switches are down |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 738 | """ |
| 739 | |
| 740 | assert main, "There is no main variable" |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 741 | assert senders, "You must specify a sender" |
| 742 | assert recipients, "You must specify a recipient" |
| 743 | # Assert devices or main.hostsData, "You must specify devices" |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 744 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 745 | global itemName # The name of this run. Used for logs. |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 746 | itemName = name |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 747 | onosNode = int( onosNode ) |
| 748 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 749 | main.log.info( itemName + ": Adding single point to multi point intents" ) |
| 750 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 751 | try: |
| 752 | for sender in senders: |
| 753 | if not sender.get( "device" ): |
| 754 | main.log.warn( "Device not given for sender {0}. Loading from main.hostData".format( sender.get( "name" ) ) ) |
| 755 | sender[ "device" ] = main.hostsData.get( sender.get( "name" ) ).get( "location" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 756 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 757 | for recipient in recipients: |
| 758 | if not recipient.get( "device" ): |
| 759 | main.log.warn( "Device not given for recipient {0}. Loading from main.hostData".format( recipient.get( "name" ) ) ) |
| 760 | recipient[ "device" ] = main.hostsData.get( recipient.get( "name" ) ).get( "location" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 761 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 762 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 763 | ingressDevice = senders[ 0 ].get( "device" ) |
| 764 | egressDeviceList = [ x.get( "device" ) for x in recipients if x.get( "device" ) ] |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 765 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 766 | portIngress = senders[ 0 ].get( "port", "" ) |
| 767 | portEgressList = [ x.get( "port" ) for x in recipients if x.get( "port" ) ] |
| 768 | if not portEgressList: |
| 769 | portEgressList = None |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 770 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 771 | srcMac = senders[ 0 ].get( "mac" ) |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 772 | vlanId = senders[ 0 ].get( "vlan" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 773 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 774 | # Adding point intent |
| 775 | intentId = main.CLIs[ onosNode ].addSinglepointToMultipointIntent( |
| 776 | ingressDevice=ingressDevice, |
| 777 | egressDeviceList=egressDeviceList, |
| 778 | portIngress=portIngress, |
| 779 | portEgressList=portEgressList, |
| 780 | ethType=ethType, |
| 781 | ethSrc=srcMac, |
| 782 | bandwidth=bandwidth, |
| 783 | lambdaAlloc=lambdaAlloc, |
| 784 | ipProto=ipProto, |
| 785 | ipSrc="", |
| 786 | ipDst="", |
| 787 | tcpSrc="", |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 788 | tcpDst="", |
Jeremy Songster | ff55367 | 2016-05-12 17:06:23 -0700 | [diff] [blame] | 789 | vlanId=vlanId, |
| 790 | setVlan=setVlan ) |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 791 | except (KeyError, TypeError): |
| 792 | errorMsg = "There was a problem loading the hosts data." |
| 793 | if intentId: |
| 794 | errorMsg += " There was a problem installing Singlepoint to Multipoint intent." |
| 795 | main.log.error( errorMsg ) |
| 796 | return main.FALSE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 797 | |
| 798 | # Check intents state |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 799 | if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [ intentId ] ), sleep=main.checkIntentSleep ): |
| 800 | return intentId |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 801 | else: |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 802 | main.log.error( "Single to Multi Intent did not install correctly" ) |
| 803 | return main.FALSE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 804 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 805 | def installMultiToSingleIntent( main, |
| 806 | name, |
| 807 | senders, |
| 808 | recipients, |
| 809 | onosNode=0, |
| 810 | ethType="", |
| 811 | bandwidth="", |
| 812 | lambdaAlloc=False, |
| 813 | ipProto="", |
| 814 | ipAddresses="", |
| 815 | tcp="", |
| 816 | sw1="", |
Jeremy Songster | ff55367 | 2016-05-12 17:06:23 -0700 | [diff] [blame] | 817 | sw2="", |
| 818 | setVlan=""): |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 819 | """ |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 820 | Installs a Multi to Single Point Intent |
| 821 | |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 822 | Description: |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 823 | Install a multi to single point intent using |
| 824 | add-multi-to-single-intent |
| 825 | |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 826 | Steps: |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 827 | - Fetch host data if not given |
| 828 | - Add multi to single intent |
| 829 | - Ingress devices are the senders devices |
| 830 | - Egress device is the first recipient host |
| 831 | - Ports if defined in senders or recipients |
| 832 | - MAC address ethSrc loaded from Ingress device |
| 833 | - Check intent state with retry |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 834 | Required: |
| 835 | name - Type of point intent to add eg. IPV4 | VLAN | Dualstack |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 836 | senders - List of host dictionaries i.e. |
| 837 | [ { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" } ] |
| 838 | recipients - List of host dictionaries i.e. |
| 839 | [ { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" } ] |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 840 | Optional: |
| 841 | onosNode - ONOS node to install the intents in main.CLIs[ ] |
| 842 | 0 by default so that it will always use the first |
| 843 | ONOS node |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 844 | ethType - Ethernet type eg. IPV4, IPV6 |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 845 | bandwidth - Bandwidth capacity |
| 846 | lambdaAlloc - Allocate lambda, defaults to False |
| 847 | ipProto - IP protocol |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 848 | tcp - TCP ports in the same order as the hosts in hostNames |
| 849 | sw1 - First switch to bring down & up for rerouting purpose |
| 850 | sw2 - Second switch to bring down & up for rerouting purpose |
| 851 | expectedLink - Expected link when the switches are down, it should |
| 852 | be two links lower than the links before the two |
| 853 | switches are down |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 854 | """ |
| 855 | |
| 856 | assert main, "There is no main variable" |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 857 | assert senders, "You must specify a sender" |
| 858 | assert recipients, "You must specify a recipient" |
| 859 | # Assert devices or main.hostsData, "You must specify devices" |
| 860 | |
| 861 | global itemName # The name of this run. Used for logs. |
| 862 | itemName = name |
| 863 | onosNode = int( onosNode ) |
| 864 | |
| 865 | main.log.info( itemName + ": Adding mutli to single point intents" ) |
| 866 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 867 | try: |
| 868 | for sender in senders: |
| 869 | if not sender.get( "device" ): |
| 870 | main.log.warn( "Device not given for sender {0}. Loading from main.hostData".format( sender.get( "name" ) ) ) |
| 871 | sender[ "device" ] = main.hostsData.get( sender.get( "name" ) ).get( "location" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 872 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 873 | for recipient in recipients: |
| 874 | if not recipient.get( "device" ): |
| 875 | main.log.warn( "Device not given for recipient {0}. Loading from main.hostData".format( recipient.get( "name" ) ) ) |
| 876 | recipient[ "device" ] = main.hostsData.get( recipient.get( "name" ) ).get( "location" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 877 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 878 | ingressDeviceList = [ x.get( "device" ) for x in senders if x.get( "device" ) ] |
| 879 | egressDevice = recipients[ 0 ].get( "device" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 880 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 881 | portIngressList = [ x.get( "port" ) for x in senders if x.get( "port" ) ] |
| 882 | portEgress = recipients[ 0 ].get( "port", "" ) |
| 883 | if not portIngressList: |
| 884 | portIngressList = None |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 885 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 886 | dstMac = recipients[ 0 ].get( "mac" ) |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 887 | vlanId = senders[ 0 ].get( "vlan" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 888 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 889 | # Adding point intent |
| 890 | intentId = main.CLIs[ onosNode ].addMultipointToSinglepointIntent( |
| 891 | ingressDeviceList=ingressDeviceList, |
| 892 | egressDevice=egressDevice, |
| 893 | portIngressList=portIngressList, |
| 894 | portEgress=portEgress, |
| 895 | ethType=ethType, |
| 896 | ethDst=dstMac, |
| 897 | bandwidth=bandwidth, |
| 898 | lambdaAlloc=lambdaAlloc, |
| 899 | ipProto=ipProto, |
| 900 | ipSrc="", |
| 901 | ipDst="", |
| 902 | tcpSrc="", |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 903 | tcpDst="", |
Jeremy Songster | ff55367 | 2016-05-12 17:06:23 -0700 | [diff] [blame] | 904 | vlanId=vlanId, |
| 905 | setVlan=setVlan ) |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 906 | except (KeyError, TypeError): |
| 907 | errorMsg = "There was a problem loading the hosts data." |
| 908 | if intentId: |
| 909 | errorMsg += " There was a problem installing Multipoint to Singlepoint intent." |
| 910 | main.log.error( errorMsg ) |
| 911 | return main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 912 | |
| 913 | # Check intents state |
| 914 | if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [ intentId ] ), sleep=main.checkIntentSleep ): |
| 915 | return intentId |
| 916 | else: |
| 917 | main.log.error( "Multi to Single Intent did not install correctly" ) |
| 918 | return main.FALSE |
| 919 | |
| 920 | def testPointIntent( main, |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 921 | name, |
| 922 | intentId, |
| 923 | senders, |
| 924 | recipients, |
| 925 | badSenders={}, |
| 926 | badRecipients={}, |
| 927 | onosNode=0, |
| 928 | ethType="", |
| 929 | bandwidth="", |
| 930 | lambdaAlloc=False, |
| 931 | ipProto="", |
| 932 | ipAddresses="", |
| 933 | tcp="", |
| 934 | sw1="s5", |
| 935 | sw2="s2", |
| 936 | expectedLink=0): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 937 | """ |
| 938 | Test a Point Intent |
| 939 | |
| 940 | Description: |
| 941 | Test a point intent |
| 942 | |
| 943 | Steps: |
| 944 | - Fetch host data if not given |
| 945 | - Check Intent State |
| 946 | - Check Flow State |
| 947 | - Check Connectivity |
| 948 | - Check Lack of Connectivity Between Hosts not in the Intent |
| 949 | - Reroute |
| 950 | - Take Expected Link Down |
| 951 | - Check Intent State |
| 952 | - Check Flow State |
| 953 | - Check Topology |
| 954 | - Check Connectivity |
| 955 | - Bring Expected Link Up |
| 956 | - Check Intent State |
| 957 | - Check Flow State |
| 958 | - Check Topology |
| 959 | - Check Connectivity |
| 960 | - Remove Topology |
| 961 | |
| 962 | Required: |
| 963 | name - Type of point intent to add eg. IPV4 | VLAN | Dualstack |
| 964 | |
| 965 | senders - List of host dictionaries i.e. |
| 966 | { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" } |
| 967 | recipients - List of host dictionaries i.e. |
| 968 | { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" } |
| 969 | Optional: |
| 970 | onosNode - ONOS node to install the intents in main.CLIs[ ] |
| 971 | 0 by default so that it will always use the first |
| 972 | ONOS node |
| 973 | ethType - Ethernet type eg. IPV4, IPV6 |
| 974 | bandwidth - Bandwidth capacity |
| 975 | lambdaAlloc - Allocate lambda, defaults to False |
| 976 | ipProto - IP protocol |
| 977 | tcp - TCP ports in the same order as the hosts in hostNames |
| 978 | sw1 - First switch to bring down & up for rerouting purpose |
| 979 | sw2 - Second switch to bring down & up for rerouting purpose |
| 980 | expectedLink - Expected link when the switches are down, it should |
| 981 | be two links lower than the links before the two |
| 982 | switches are down |
| 983 | |
| 984 | """ |
| 985 | |
| 986 | # Parameter Validity Check |
| 987 | assert main, "There is no main variable" |
| 988 | assert senders, "You must specify a sender" |
| 989 | assert recipients, "You must specify a recipient" |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 990 | |
| 991 | global itemName |
| 992 | itemName = name |
| 993 | tempHostsData = {} |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 994 | onosNode = int( onosNode ) |
| 995 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 996 | main.log.info( itemName + ": Testing Point Intent" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 997 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 998 | try: |
| 999 | # Names for scapy |
| 1000 | senderNames = [ x.get( "name" ) for x in senders ] |
| 1001 | recipientNames = [ x.get( "name" ) for x in recipients ] |
| 1002 | badSenderNames = [ x.get( "name" ) for x in badSenders ] |
| 1003 | badRecipientNames = [ x.get( "name" ) for x in badRecipients ] |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1004 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1005 | for sender in senders: |
| 1006 | if not sender.get( "device" ): |
| 1007 | main.log.warn( "Device not given for sender {0}. Loading from main.hostData".format( sender.get( "name" ) ) ) |
| 1008 | sender[ "device" ] = main.hostsData.get( sender.get( "name" ) ).get( "location" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1009 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1010 | for recipient in recipients: |
| 1011 | if not recipient.get( "device" ): |
| 1012 | main.log.warn( "Device not given for recipient {0}. Loading from main.hostData".format( recipient.get( "name" ) ) ) |
| 1013 | recipient[ "device" ] = main.hostsData.get( recipient.get( "name" ) ).get( "location" ) |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 1014 | vlanId = senders[ 0 ].get( "vlan" ) |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1015 | except (KeyError, TypeError): |
| 1016 | main.log.error( "There was a problem loading the hosts data." ) |
| 1017 | return main.FALSE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1018 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1019 | testResult = main.TRUE |
| 1020 | main.log.info( itemName + ": Adding single point to multi point intents" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1021 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1022 | # Check intent state |
| 1023 | if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [ intentId ] ), sleep=main.checkIntentSleep ): |
| 1024 | main.assertReturnString += 'Initial Intent State Passed\n' |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 1025 | else: |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1026 | main.assertReturnString += 'Initial Intent State Failed\n' |
| 1027 | testResult = main.FALSE |
| 1028 | |
| 1029 | # Check flows count in each node |
Jeremy | 03dab01 | 2016-04-11 08:59:17 -0700 | [diff] [blame] | 1030 | if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ) and utilities.retry( f=checkFlowsState, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1031 | main.assertReturnString += 'Initial Flow State Passed\n' |
| 1032 | else: |
| 1033 | main.assertReturnString += 'Intial Flow State Failed\n' |
| 1034 | testResult = main.FALSE |
| 1035 | |
| 1036 | # Check Connectivity |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 1037 | if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId ), attempts=3, sleep=5 ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1038 | main.assertReturnString += 'Initial Ping Passed\n' |
| 1039 | else: |
| 1040 | main.assertReturnString += 'Initial Ping Failed\n' |
| 1041 | testResult = main.FALSE |
| 1042 | |
| 1043 | # Check connections that shouldn't work |
| 1044 | if badSenderNames: |
| 1045 | main.log.info( "Checking that packets from incorrect sender do not go through" ) |
| 1046 | if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, badSenderNames, recipientNames ), kwargs={ "expectFailure":True } ): |
| 1047 | main.assertReturnString += 'Bad Sender Ping Passed\n' |
| 1048 | else: |
| 1049 | main.assertReturnString += 'Bad Sender Ping Failed\n' |
| 1050 | testResult = main.FALSE |
| 1051 | |
| 1052 | if badRecipientNames: |
| 1053 | main.log.info( "Checking that packets to incorrect recipients do not go through" ) |
| 1054 | if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, badRecipientNames ), kwargs={ "expectFailure":True } ): |
| 1055 | main.assertReturnString += 'Bad Recipient Ping Passed\n' |
| 1056 | else: |
| 1057 | main.assertReturnString += 'Bad Recipient Ping Failed\n' |
| 1058 | testResult = main.FALSE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1059 | |
| 1060 | # Test rerouting if these variables exist |
| 1061 | if sw1 and sw2 and expectedLink: |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1062 | # Take link down |
| 1063 | if utilities.retry( f=link, retValue=main.FALSE, args=( main, sw1, sw2, "down" ) ): |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 1064 | main.assertReturnString += 'Link Down Passed\n' |
| 1065 | else: |
| 1066 | main.assertReturnString += 'Link Down Failed\n' |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1067 | testResult = main.FALSE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1068 | |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 1069 | # Check intent state |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1070 | if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [ intentId ] ), sleep=main.checkIntentSleep ): |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 1071 | main.assertReturnString += 'Link Down Intent State Passed\n' |
| 1072 | else: |
| 1073 | main.assertReturnString += 'Link Down Intent State Failed\n' |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1074 | testResult = main.FALSE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1075 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1076 | # Check flows count in each node |
Jeremy | 03dab01 | 2016-04-11 08:59:17 -0700 | [diff] [blame] | 1077 | if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ) and utilities.retry( f=checkFlowsState, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1078 | main.assertReturnString += 'Link Down Flow State Passed\n' |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1079 | else: |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1080 | main.assertReturnString += 'Link Down Flow State Failed\n' |
| 1081 | testResult = main.FALSE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1082 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1083 | # Check OnosTopology |
| 1084 | if utilities.retry( f=checkTopology, retValue=main.FALSE, args=( main, expectedLink ) ): |
| 1085 | main.assertReturnString += 'Link Down Topology State Passed\n' |
| 1086 | else: |
| 1087 | main.assertReturnString += 'Link Down Topology State Failed\n' |
| 1088 | testResult = main.FALSE |
| 1089 | |
| 1090 | # Check Connection |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 1091 | if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId ) ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1092 | main.assertReturnString += 'Link Down Pingall Passed\n' |
| 1093 | else: |
| 1094 | main.assertReturnString += 'Link Down Pingall Failed\n' |
| 1095 | testResult = main.FALSE |
| 1096 | |
| 1097 | # Bring link up |
| 1098 | if utilities.retry( f=link, retValue=main.FALSE, args=( main, sw1, sw2, "up" ) ): |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 1099 | main.assertReturnString += 'Link Up Passed\n' |
| 1100 | else: |
| 1101 | main.assertReturnString += 'Link Up Failed\n' |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1102 | testResult = main.FALSE |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 1103 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1104 | # Wait for reroute |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1105 | time.sleep( main.rerouteSleep ) |
| 1106 | |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 1107 | # Check Intents |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1108 | if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [ intentId ] ), sleep=main.checkIntentSleep ): |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 1109 | main.assertReturnString += 'Link Up Intent State Passed\n' |
| 1110 | else: |
| 1111 | main.assertReturnString += 'Link Up Intent State Failed\n' |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1112 | testResult = main.FALSE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1113 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1114 | # Check flows count in each node |
Jeremy | 03dab01 | 2016-04-11 08:59:17 -0700 | [diff] [blame] | 1115 | if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ) and utilities.retry( f=checkFlowsState, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1116 | main.assertReturnString += 'Link Up Flow State Passed\n' |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1117 | else: |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1118 | main.assertReturnString += 'Link Up Flow State Failed\n' |
| 1119 | testResult = main.FALSE |
| 1120 | |
| 1121 | # Check OnosTopology |
| 1122 | if utilities.retry( f=checkTopology, retValue=main.FALSE, args=( main, main.numLinks ) ): |
| 1123 | main.assertReturnString += 'Link Up Topology State Passed\n' |
| 1124 | else: |
| 1125 | main.assertReturnString += 'Link Up Topology State Failed\n' |
| 1126 | testResult = main.FALSE |
| 1127 | |
| 1128 | # Check Connection |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 1129 | if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId ) ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1130 | main.assertReturnString += 'Link Up Scapy Packet Received Passed\n' |
| 1131 | else: |
| 1132 | main.assertReturnString += 'Link Up Scapy Packet Recieved Failed\n' |
| 1133 | testResult = main.FALSE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1134 | |
| 1135 | # Remove all intents |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1136 | if utilities.retry( f=removeAllIntents, retValue=main.FALSE, args=( main, [ intentId ] ) ): |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 1137 | main.assertReturnString += 'Remove Intents Passed' |
| 1138 | else: |
| 1139 | main.assertReturnString += 'Remove Intents Failed' |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1140 | testResult = main.FALSE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1141 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1142 | return testResult |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1143 | |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1144 | def testEndPointFail( main, |
| 1145 | name, |
| 1146 | intentId, |
| 1147 | senders, |
| 1148 | recipients, |
| 1149 | isolatedSenders, |
| 1150 | isolatedRecipients, |
| 1151 | onosNode=0, |
| 1152 | ethType="", |
| 1153 | bandwidth="", |
| 1154 | lambdaAlloc=False, |
| 1155 | ipProto="", |
| 1156 | ipAddresses="", |
| 1157 | tcp="", |
| 1158 | sw1="", |
| 1159 | sw2="", |
| 1160 | sw3="", |
| 1161 | sw4="", |
| 1162 | sw5="", |
| 1163 | expectedLink1=0, |
| 1164 | expectedLink2=0 ): |
| 1165 | """ |
| 1166 | Test Single to Multipoint Topology for Endpoint failures |
| 1167 | """ |
| 1168 | |
| 1169 | # Parameter Validity Check |
| 1170 | assert main, "There is no main variable" |
| 1171 | assert senders, "You must specify a sender" |
| 1172 | assert recipients, "You must specify a recipient" |
| 1173 | |
| 1174 | global itemName |
| 1175 | itemName = name |
| 1176 | tempHostsData = {} |
| 1177 | onosNode = int( onosNode ) |
| 1178 | |
| 1179 | main.log.info( itemName + ": Testing Point Intent" ) |
| 1180 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1181 | try: |
| 1182 | # Names for scapy |
| 1183 | senderNames = [ x.get( "name" ) for x in senders ] |
| 1184 | recipientNames = [ x.get( "name" ) for x in recipients ] |
| 1185 | isolatedSenderNames = [ x.get( "name" ) for x in isolatedSenders ] |
| 1186 | isolatedRecipientNames = [ x.get( "name" ) for x in isolatedRecipients ] |
| 1187 | connectedSenderNames = [x.get("name") for x in senders if x.get("name") not in isolatedSenderNames] |
| 1188 | connectedRecipientNames = [x.get("name") for x in recipients if x.get("name") not in isolatedRecipientNames] |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1189 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1190 | for sender in senders: |
| 1191 | if not sender.get( "device" ): |
| 1192 | main.log.warn( "Device not given for sender {0}. Loading from main.hostData".format( sender.get( "name" ) ) ) |
| 1193 | sender[ "device" ] = main.hostsData.get( sender.get( "name" ) ).get( "location" ) |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1194 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1195 | for recipient in recipients: |
| 1196 | if not recipient.get( "device" ): |
| 1197 | main.log.warn( "Device not given for recipient {0}. Loading from\ |
| 1198 | main.hostData".format( recipient.get( "name" ) ) ) |
| 1199 | recipient[ "device" ] = main.hostsData.get( recipient.get( "name" ) ).get( "location" ) |
| 1200 | except (KeyError, TypeError): |
| 1201 | main.log.error( "There was a problem loading the hosts data." ) |
| 1202 | return main.FALSE |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1203 | |
| 1204 | testResult = main.TRUE |
| 1205 | main.log.info( itemName + ": Adding multi point to single point intents" ) |
| 1206 | |
| 1207 | # Check intent state |
| 1208 | if utilities.retry( f=checkIntentState, retValue=main.FALSE, |
| 1209 | args=( main, [ intentId ] ), sleep=main.checkIntentSleep ): |
| 1210 | main.assertReturnString += 'Initial Intent State Passed\n' |
| 1211 | else: |
| 1212 | main.assertReturnString += 'Initial Intent State Failed\n' |
| 1213 | testResult = main.FALSE |
| 1214 | |
| 1215 | # Check flows count in each node |
| 1216 | if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, |
| 1217 | args=[ main ] ) and utilities.retry( f=checkFlowsState, |
| 1218 | retValue=main.FALSE, |
| 1219 | args=[ main ] ): |
| 1220 | main.assertReturnString += 'Initial Flow State Passed\n' |
| 1221 | else: |
| 1222 | main.assertReturnString += 'Intial Flow State Failed\n' |
| 1223 | testResult = main.FALSE |
| 1224 | |
| 1225 | # Check Connectivity |
| 1226 | if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, |
| 1227 | args=( main, senderNames, recipientNames ) ): |
| 1228 | main.assertReturnString += 'Initial Connectivity Check Passed\n' |
| 1229 | else: |
| 1230 | main.assertReturnString += 'Initial Connectivity Check Failed\n' |
| 1231 | testResult = main.FALSE |
| 1232 | |
| 1233 | # Take two links down |
| 1234 | # Take first link down |
| 1235 | if utilities.retry( f=link, retValue=main.FALSE, args=( main, sw1, sw2, "down" ) ): |
| 1236 | main.assertReturnString += 'Link Down Passed\n' |
| 1237 | else: |
| 1238 | main.assertReturnString += 'Link Down Failed\n' |
| 1239 | testResult = main.FALSE |
| 1240 | |
| 1241 | # Take second link down |
| 1242 | if utilities.retry( f=link, retValue=main.FALSE, args=( main, sw3, sw4, "down" ) ): |
| 1243 | main.assertReturnString += 'Link Down Passed\n' |
| 1244 | else: |
| 1245 | main.assertReturnString += 'Link Down Failed\n' |
| 1246 | testResult = main.FALSE |
| 1247 | |
| 1248 | # Check intent state |
| 1249 | if utilities.retry( f=checkIntentState, retValue=main.FALSE, |
| 1250 | args=( main, [ intentId ] ), sleep=main.checkIntentSleep ): |
| 1251 | main.assertReturnString += 'Link Down Intent State Passed\n' |
| 1252 | else: |
| 1253 | main.assertReturnString += 'Link Down Intent State Failed\n' |
| 1254 | testResult = main.FALSE |
| 1255 | |
| 1256 | # Check flows count in each node |
| 1257 | if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, |
| 1258 | args=[ main ] ) and utilities.retry( f=checkFlowsState, |
| 1259 | retValue=main.FALSE, args=[ main ] ): |
| 1260 | main.assertReturnString += 'Link Down Flow State Passed\n' |
| 1261 | else: |
| 1262 | main.assertReturnString += 'Link Down Flow State Failed\n' |
| 1263 | testResult = main.FALSE |
| 1264 | |
| 1265 | # Check OnosTopology |
| 1266 | if utilities.retry( f=checkTopology, retValue=main.FALSE, args=( main, expectedLink1 ) ): |
| 1267 | main.assertReturnString += 'Link Down Topology State Passed\n' |
| 1268 | else: |
| 1269 | main.assertReturnString += 'Link Down Topology State Failed\n' |
| 1270 | testResult = main.FALSE |
| 1271 | |
| 1272 | # Check Connection |
| 1273 | if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, |
| 1274 | args=( main, senderNames, recipientNames ) ): |
| 1275 | main.assertReturnString += 'Link Down Connectivity Check Passed\n' |
| 1276 | else: |
| 1277 | main.assertReturnString += 'Link Down Connectivity Check Failed\n' |
| 1278 | testResult = main.FALSE |
| 1279 | |
| 1280 | # Take a third link down to isolate one node |
| 1281 | if utilities.retry( f=link, retValue=main.FALSE, args=( main, sw3, sw5, "down" ) ): |
| 1282 | main.assertReturnString += 'Isolation link Down Passed\n' |
| 1283 | else: |
| 1284 | main.assertReturnString += 'Isolation link Down Failed\n' |
| 1285 | testResult = main.FALSE |
| 1286 | |
| 1287 | # Check intent state |
| 1288 | if utilities.retry( f=checkIntentState, retValue=main.FALSE, |
| 1289 | args=( main, [ intentId ] ), sleep=main.checkIntentSleep ): |
| 1290 | main.assertReturnString += 'Isolation link Down Intent State Passed\n' |
| 1291 | else: |
| 1292 | main.assertReturnString += 'Isolation link Down Intent State Failed\n' |
| 1293 | testResult = main.FALSE |
| 1294 | |
| 1295 | # Check flows count in each node |
| 1296 | if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, |
| 1297 | args=[ main ] ) and utilities.retry( f=checkFlowsState, |
| 1298 | retValue=main.FALSE, args=[ main ] ): |
| 1299 | main.assertReturnString += 'Isolation link Down Flow State Passed\n' |
| 1300 | else: |
| 1301 | main.assertReturnString += 'Isolation link Down Flow State Failed\n' |
| 1302 | testResult = main.FALSE |
| 1303 | |
| 1304 | # Check OnosTopology |
| 1305 | if utilities.retry( f=checkTopology, retValue=main.FALSE, args=( main, expectedLink2 ) ): |
| 1306 | main.assertReturnString += 'Isolation link Down Topology State Passed\n' |
| 1307 | else: |
| 1308 | main.assertReturnString += 'Isolation link Down Topology State Failed\n' |
| 1309 | testResult = main.FALSE |
| 1310 | |
| 1311 | # Check Connectivity |
| 1312 | # First check connectivity of any isolated senders to recipients |
| 1313 | if isolatedSenderNames: |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 1314 | if scapyCheckConnection( main, isolatedSenderNames, recipientNames, None, None, None, main.TRUE ): |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1315 | main.assertReturnString += 'Isolation link Down Connectivity Check Passed\n' |
| 1316 | else: |
| 1317 | main.assertReturnString += 'Isolation link Down Connectivity Check Failed\n' |
| 1318 | testResult = main.FALSE |
| 1319 | |
| 1320 | # Next check connectivity of senders to any isolated recipients |
| 1321 | if isolatedRecipientNames: |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 1322 | if scapyCheckConnection( main, senderNames, isolatedRecipientNames, None, None, None, main.TRUE ): |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1323 | main.assertReturnString += 'Isolation link Down Connectivity Check Passed\n' |
| 1324 | else: |
| 1325 | main.assertReturnString += 'Isolation link Down Connectivity Check Failed\n' |
| 1326 | testResult = main.FALSE |
| 1327 | |
| 1328 | # Next check connectivity of connected senders and recipients |
| 1329 | if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, |
| 1330 | args=( main, connectedSenderNames , connectedRecipientNames ) ): |
| 1331 | main.assertReturnString += 'Isolation link Down Connectivity Check Passed\n' |
| 1332 | else: |
| 1333 | main.assertReturnString += 'Isolation link Down Connectivity Check Failed\n' |
| 1334 | testResult = main.FALSE |
| 1335 | |
| 1336 | # Bring the links back up |
| 1337 | # Bring first link up |
| 1338 | if utilities.retry( f=link, retValue=main.FALSE, args=( main, sw1, sw2, "up" ) ): |
| 1339 | main.assertReturnString += 'Link Up Passed\n' |
| 1340 | else: |
| 1341 | main.assertReturnString += 'Link Up Failed\n' |
| 1342 | testResult = main.FALSE |
| 1343 | |
| 1344 | # Bring second link up |
| 1345 | if utilities.retry( f=link, retValue=main.FALSE, args=( main, sw3, sw5, "up" ) ): |
| 1346 | main.assertReturnString += 'Link Up Passed\n' |
| 1347 | else: |
| 1348 | main.assertReturnString += 'Link Up Failed\n' |
| 1349 | testResult = main.FALSE |
| 1350 | |
| 1351 | # Bring third link up |
| 1352 | if utilities.retry( f=link, retValue=main.FALSE, args=( main, sw3, sw4, "up" ) ): |
| 1353 | main.assertReturnString += 'Link Up Passed\n' |
| 1354 | else: |
| 1355 | main.assertReturnString += 'Link Up Failed\n' |
| 1356 | testResult = main.FALSE |
| 1357 | |
| 1358 | # Wait for reroute |
| 1359 | time.sleep( main.rerouteSleep ) |
| 1360 | |
| 1361 | # Check Intents |
| 1362 | if utilities.retry( f=checkIntentState, retValue=main.FALSE, |
| 1363 | args=( main, [ intentId ] ), sleep=main.checkIntentSleep ): |
| 1364 | main.assertReturnString += 'Link Up Intent State Passed\n' |
| 1365 | else: |
| 1366 | main.assertReturnString += 'Link Up Intent State Failed\n' |
| 1367 | testResult = main.FALSE |
| 1368 | |
| 1369 | # Check flows count in each node |
| 1370 | if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, |
| 1371 | args=[ main ] ) and utilities.retry( f=checkFlowsState, |
| 1372 | retValue=main.FALSE, args=[ main ] ): |
| 1373 | main.assertReturnString += 'Link Up Flow State Passed\n' |
| 1374 | else: |
| 1375 | main.assertReturnString += 'Link Up Flow State Failed\n' |
| 1376 | testResult = main.FALSE |
| 1377 | |
| 1378 | # Check OnosTopology |
| 1379 | if utilities.retry( f=checkTopology, retValue=main.FALSE, args=( main, main.numLinks ) ): |
| 1380 | main.assertReturnString += 'Link Up Topology State Passed\n' |
| 1381 | else: |
| 1382 | main.assertReturnString += 'Link Up Topology State Failed\n' |
| 1383 | testResult = main.FALSE |
| 1384 | |
| 1385 | # Check Connection |
| 1386 | if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, |
| 1387 | args=( main, senderNames, recipientNames ) ): |
| 1388 | main.assertReturnString += 'Link Up Scapy Packet Received Passed\n' |
| 1389 | else: |
| 1390 | main.assertReturnString += 'Link Up Scapy Packet Recieved Failed\n' |
| 1391 | testResult = main.FALSE |
| 1392 | |
| 1393 | # Remove all intents |
| 1394 | if utilities.retry( f=removeAllIntents, retValue=main.FALSE, args=( main, [ intentId ] ) ): |
| 1395 | main.assertReturnString += 'Remove Intents Passed' |
| 1396 | else: |
| 1397 | main.assertReturnString += 'Remove Intents Failed' |
| 1398 | testResult = main.FALSE |
| 1399 | |
| 1400 | return testResult |
| 1401 | |
| 1402 | |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 1403 | def pingallHosts( main, hostList ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1404 | """ |
| 1405 | Ping all host in the hosts list variable |
| 1406 | """ |
Jon Hall | a5cb341 | 2015-08-18 14:08:22 -0700 | [diff] [blame] | 1407 | main.log.info( "Pinging: " + str( hostList ) ) |
| 1408 | return main.Mininet1.pingallHosts( hostList ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1409 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1410 | def fwdPingall( main ): |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1411 | """ |
| 1412 | Use fwd app and pingall to discover all the hosts |
| 1413 | """ |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1414 | activateResult = main.TRUE |
| 1415 | appCheck = main.TRUE |
| 1416 | getDataResult = main.TRUE |
| 1417 | main.log.info( "Activating reactive forwarding app " ) |
| 1418 | activateResult = main.CLIs[ 0 ].activateApp( "org.onosproject.fwd" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1419 | |
| 1420 | # Wait for forward app activation to propagate |
kelvin-onlab | 0ad05d1 | 2015-07-23 14:21:15 -0700 | [diff] [blame] | 1421 | time.sleep( main.fwdSleep ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1422 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1423 | # Check that forwarding is enabled on all nodes |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1424 | for i in range( main.numCtrls ): |
| 1425 | appCheck = appCheck and main.CLIs[ i ].appToIDCheck() |
| 1426 | if appCheck != main.TRUE: |
| 1427 | main.log.warn( main.CLIs[ i ].apps() ) |
| 1428 | main.log.warn( main.CLIs[ i ].appIDs() ) |
| 1429 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1430 | # Send pingall in mininet |
| 1431 | main.log.info( "Run Pingall" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1432 | pingResult = main.Mininet1.pingall( timeout = 600 ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1433 | |
| 1434 | main.log.info( "Deactivating reactive forwarding app " ) |
| 1435 | deactivateResult = main.CLIs[ 0 ].deactivateApp( "org.onosproject.fwd" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1436 | if activateResult and deactivateResult: |
| 1437 | main.log.info( "Successfully used fwd app to discover hosts" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1438 | getDataResult = main.TRUE |
| 1439 | else: |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1440 | main.log.info( "Failed to use fwd app to discover hosts" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1441 | getDataResult = main.FALSE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1442 | return getDataResult |
| 1443 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1444 | def confirmHostDiscovery( main ): |
| 1445 | """ |
| 1446 | Confirms that all ONOS nodes have discovered all scapy hosts |
| 1447 | """ |
| 1448 | import collections |
| 1449 | scapyHostCount = len( main.scapyHosts ) |
| 1450 | hosts = main.topo.getAllHosts( main ) # Get host data from each ONOS node |
| 1451 | hostFails = [] # Reset for each failed attempt |
| 1452 | |
| 1453 | # Check for matching hosts on each node |
| 1454 | scapyHostIPs = [ x.hostIp for x in main.scapyHosts if x.hostIp != "0.0.0.0" ] |
| 1455 | for controller in range( main.numCtrls ): |
| 1456 | controllerStr = str( controller + 1 ) # ONOS node number |
| 1457 | # Compare Hosts |
| 1458 | # Load hosts data for controller node |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1459 | try: |
| 1460 | if hosts[ controller ]: |
| 1461 | main.log.info( "Hosts discovered" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1462 | else: |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1463 | main.log.error( "Problem discovering hosts" ) |
| 1464 | if hosts[ controller ] and "Error" not in hosts[ controller ]: |
| 1465 | try: |
| 1466 | hostData = json.loads( hosts[ controller ] ) |
| 1467 | except ( TypeError, ValueError ): |
| 1468 | main.log.error( "Could not load json:" + str( hosts[ controller ] ) ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1469 | hostFails.append( controllerStr ) |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1470 | else: |
| 1471 | onosHostIPs = [ x.get( "ipAddresses" )[ 0 ] |
| 1472 | for x in hostData |
| 1473 | if len( x.get( "ipAddresses" ) ) > 0 ] |
| 1474 | if not set( collections.Counter( scapyHostIPs ) ).issubset( set ( collections.Counter( onosHostIPs ) ) ): |
| 1475 | main.log.warn( "Controller {0} only sees nodes with {1} IPs. It should see all of the following: {2}".format( controllerStr, onosHostIPs, scapyHostIPs ) ) |
| 1476 | hostFails.append( controllerStr ) |
| 1477 | else: |
| 1478 | main.log.error( "Hosts returned nothing or an error." ) |
| 1479 | hostFails.append( controllerStr ) |
| 1480 | except IndexError: |
| 1481 | main.log.error( "Hosts returned nothing, Failed to discover hosts." ) |
| 1482 | return main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1483 | |
| 1484 | if hostFails: |
| 1485 | main.log.error( "List of failed ONOS Nodes:" + ', '.join(map(str, hostFails )) ) |
| 1486 | return main.FALSE |
| 1487 | else: |
| 1488 | return main.TRUE |
| 1489 | |
| 1490 | def sendDiscoveryArp( main, hosts=None ): |
| 1491 | """ |
| 1492 | Sends Discovery ARP packets from each host provided |
| 1493 | Defaults to each host in main.scapyHosts |
| 1494 | """ |
| 1495 | # Send an arp ping from each host |
| 1496 | if not hosts: |
| 1497 | hosts = main.scapyHosts |
| 1498 | for host in hosts: |
| 1499 | pkt = 'Ether( src="{0}")/ARP( psrc="{1}")'.format( host.hostMac ,host.hostIp ) |
| 1500 | # Send from the VLAN interface if there is one so ONOS discovers the VLAN correctly |
| 1501 | iface = None |
| 1502 | for interface in host.getIfList(): |
| 1503 | if '.' in interface: |
| 1504 | main.log.debug( "Detected VLAN interface {0}. Sending ARP packet from {0}".format( interface ) ) |
| 1505 | iface = interface |
| 1506 | break |
| 1507 | host.sendPacket( packet=pkt, iface=iface ) |
| 1508 | main.log.info( "Sending ARP packet from {0}".format( host.name ) ) |
| 1509 | |
| 1510 | def populateHostData( main ): |
| 1511 | """ |
| 1512 | Populates hostsData |
| 1513 | """ |
| 1514 | import json |
| 1515 | try: |
| 1516 | hostsJson = json.loads( main.CLIs[ 0 ].hosts() ) |
| 1517 | hosts = main.Mininet1.getHosts().keys() |
| 1518 | # TODO: Make better use of new getHosts function |
| 1519 | for host in hosts: |
| 1520 | main.hostsData[ host ] = {} |
| 1521 | main.hostsData[ host ][ 'mac' ] = \ |
| 1522 | main.Mininet1.getMacAddress( host ).upper() |
| 1523 | for hostj in hostsJson: |
| 1524 | if main.hostsData[ host ][ 'mac' ] == hostj[ 'mac' ]: |
| 1525 | main.hostsData[ host ][ 'id' ] = hostj[ 'id' ] |
| 1526 | main.hostsData[ host ][ 'vlan' ] = hostj[ 'vlan' ] |
| 1527 | main.hostsData[ host ][ 'location' ] = \ |
| 1528 | hostj[ 'location' ][ 'elementId' ] + '/' + \ |
| 1529 | hostj[ 'location' ][ 'port' ] |
| 1530 | main.hostsData[ host ][ 'ipAddresses' ] = hostj[ 'ipAddresses' ] |
| 1531 | return main.TRUE |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1532 | except ValueError: |
| 1533 | main.log.error( "ValueError while populating hostsData" ) |
| 1534 | return main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1535 | except KeyError: |
| 1536 | main.log.error( "KeyError while populating hostsData") |
| 1537 | return main.FALSE |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1538 | except IndexError: |
| 1539 | main.log.error( "IndexError while populating hostsData" ) |
| 1540 | return main.FALSE |
| 1541 | except TypeError: |
| 1542 | main.log.error( "TypeError while populating hostsData" ) |
| 1543 | return main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1544 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1545 | def checkTopology( main, expectedLink ): |
| 1546 | statusResult = main.TRUE |
| 1547 | # Check onos topology |
| 1548 | main.log.info( itemName + ": Checking ONOS topology " ) |
| 1549 | |
| 1550 | for i in range( main.numCtrls ): |
| 1551 | topologyResult = main.CLIs[ i ].topology() |
You Wang | 2413987 | 2016-05-03 11:48:47 -0700 | [diff] [blame] | 1552 | statusResult = main.CLIs[ i ].checkStatus( topologyResult, |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1553 | main.numSwitch, |
| 1554 | expectedLink )\ |
| 1555 | and statusResult |
| 1556 | if not statusResult: |
| 1557 | main.log.error( itemName + ": Topology mismatch" ) |
| 1558 | else: |
| 1559 | main.log.info( itemName + ": Topology match" ) |
| 1560 | return statusResult |
| 1561 | |
| 1562 | def checkIntentState( main, intentsId ): |
| 1563 | """ |
| 1564 | This function will check intent state to make sure all the intents |
| 1565 | are in INSTALLED state |
| 1566 | """ |
| 1567 | |
| 1568 | intentResult = main.TRUE |
| 1569 | results = [] |
| 1570 | |
| 1571 | main.log.info( itemName + ": Checking intents state" ) |
| 1572 | # First check of intents |
| 1573 | for i in range( main.numCtrls ): |
| 1574 | tempResult = main.CLIs[ i ].checkIntentState( intentsId=intentsId ) |
| 1575 | results.append( tempResult ) |
| 1576 | |
| 1577 | expectedState = [ 'INSTALLED', 'INSTALLING' ] |
| 1578 | |
| 1579 | if all( result == main.TRUE for result in results ): |
| 1580 | main.log.info( itemName + ": Intents are installed correctly" ) |
| 1581 | else: |
| 1582 | # Wait for at least 5 second before checking the intents again |
acsmars | b9a9269 | 2015-10-08 16:43:01 -0700 | [diff] [blame] | 1583 | main.log.error( "Intents are not installed correctly. Waiting 5 sec" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1584 | time.sleep( 5 ) |
| 1585 | results = [] |
| 1586 | # Second check of intents since some of the intents may be in |
| 1587 | # INSTALLING state, they should be in INSTALLED at this time |
| 1588 | for i in range( main.numCtrls ): |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1589 | tempResult = main.CLIs[ i ].checkIntentState( intentsId=intentsId ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1590 | results.append( tempResult ) |
| 1591 | if all( result == main.TRUE for result in results ): |
| 1592 | main.log.info( itemName + ": Intents are installed correctly" ) |
acsmars | b9a9269 | 2015-10-08 16:43:01 -0700 | [diff] [blame] | 1593 | intentResult = main.TRUE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1594 | else: |
| 1595 | main.log.error( itemName + ": Intents are NOT installed correctly" ) |
| 1596 | intentResult = main.FALSE |
| 1597 | |
| 1598 | return intentResult |
| 1599 | |
| 1600 | def checkFlowsState( main ): |
| 1601 | |
| 1602 | main.log.info( itemName + ": Check flows state" ) |
Jeremy Songster | ff55367 | 2016-05-12 17:06:23 -0700 | [diff] [blame] | 1603 | checkFlowsResult = main.CLIs[ 0 ].checkFlowsState( isPENDING=False ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1604 | return checkFlowsResult |
| 1605 | |
| 1606 | def link( main, sw1, sw2, option): |
| 1607 | |
| 1608 | # link down |
| 1609 | main.log.info( itemName + ": Bring link " + option + "between " + |
| 1610 | sw1 + " and " + sw2 ) |
| 1611 | linkResult = main.Mininet1.link( end1=sw1, end2=sw2, option=option ) |
| 1612 | return linkResult |
| 1613 | |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 1614 | def scapyCheckConnection( main, senders, recipients, vlanId=None, packet=None, packetFilter=None, expectFailure=False ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1615 | """ |
| 1616 | Checks the connectivity between all given sender hosts and all given recipient hosts |
| 1617 | Packet may be specified. Defaults to Ether/IP packet |
| 1618 | Packet Filter may be specified. Defaults to Ether/IP from current sender MAC |
| 1619 | Todo: Optional packet and packet filter attributes for sender and recipients |
| 1620 | Expect Failure when the sender and recipient are not supposed to have connectivity |
| 1621 | Timeout of 1 second, returns main.TRUE if the filter is not triggered and kills the filter |
| 1622 | |
| 1623 | """ |
| 1624 | connectionsFunctional = main.TRUE |
| 1625 | |
| 1626 | if not packetFilter: |
| 1627 | packetFilter = 'ether host {}' |
| 1628 | |
| 1629 | if expectFailure: |
| 1630 | timeout = 1 |
| 1631 | else: |
| 1632 | timeout = 10 |
| 1633 | |
| 1634 | for sender in senders: |
| 1635 | try: |
| 1636 | senderComp = getattr( main, sender ) |
| 1637 | except AttributeError: |
| 1638 | main.log.error( "main has no attribute {}".format( sender ) ) |
| 1639 | connectionsFunctional = main.FALSE |
| 1640 | continue |
| 1641 | |
| 1642 | for recipient in recipients: |
| 1643 | # Do not send packets to self since recipient CLI will already be busy |
| 1644 | if recipient == sender: |
| 1645 | continue |
| 1646 | try: |
| 1647 | recipientComp = getattr( main, recipient ) |
| 1648 | except AttributeError: |
| 1649 | main.log.error( "main has no attribute {}".format( recipient ) ) |
| 1650 | connectionsFunctional = main.FALSE |
| 1651 | continue |
| 1652 | |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 1653 | if vlanId: |
| 1654 | recipientComp.startFilter( pktFilter = ( "vlan {}".format( vlanId ) + " && " + packetFilter.format( senderComp.hostMac ) ) ) |
| 1655 | else: |
| 1656 | recipientComp.startFilter( pktFilter = packetFilter.format( senderComp.hostMac ) ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1657 | |
| 1658 | if not packet: |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 1659 | if vlanId: |
| 1660 | pkt = 'Ether( src="{0}", dst="{2}" )/Dot1Q(vlan={4})/IP( src="{1}", dst="{3}" )'.format( |
| 1661 | senderComp.hostMac, |
| 1662 | senderComp.hostIp, |
| 1663 | recipientComp.hostMac, |
| 1664 | recipientComp.hostIp, |
| 1665 | vlanId ) |
| 1666 | else: |
| 1667 | pkt = 'Ether( src="{0}", dst="{2}" )/IP( src="{1}", dst="{3}" )'.format( |
| 1668 | senderComp.hostMac, |
| 1669 | senderComp.hostIp, |
| 1670 | recipientComp.hostMac, |
| 1671 | recipientComp.hostIp ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1672 | else: |
| 1673 | pkt = packet |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 1674 | if vlanId: |
| 1675 | senderComp.sendPacket( iface=( "{0}-eth0.{1}".format( sender, vlanId ) ), packet = pkt ) |
| 1676 | else: |
| 1677 | senderComp.sendPacket( packet = pkt ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1678 | |
| 1679 | if recipientComp.checkFilter( timeout ): |
| 1680 | if expectFailure: |
| 1681 | main.log.error( "Packet from {0} successfully received by {1} when it should not have been".format( sender , recipient ) ) |
| 1682 | connectionsFunctional = main.FALSE |
| 1683 | else: |
| 1684 | main.log.info( "Packet from {0} successfully received by {1}".format( sender , recipient ) ) |
| 1685 | else: |
| 1686 | recipientComp.killFilter() |
| 1687 | if expectFailure: |
| 1688 | main.log.info( "As expected, packet from {0} was not received by {1}".format( sender , recipient ) ) |
| 1689 | else: |
| 1690 | main.log.error( "Packet from {0} was not received by {1}".format( sender , recipient ) ) |
| 1691 | connectionsFunctional = main.FALSE |
| 1692 | |
| 1693 | return connectionsFunctional |
| 1694 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1695 | def removeAllIntents( main, intentsId ): |
| 1696 | """ |
| 1697 | Remove all intents in the intentsId |
| 1698 | """ |
| 1699 | |
kelvin-onlab | 5c706ff | 2015-07-20 10:56:52 -0700 | [diff] [blame] | 1700 | onosSummary = [] |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1701 | removeIntentResult = main.TRUE |
| 1702 | # Remove intents |
| 1703 | for intent in intentsId: |
| 1704 | main.CLIs[ 0 ].removeIntent( intentId=intent, purge=True ) |
| 1705 | |
acsmars | cfa5227 | 2015-08-06 15:21:45 -0700 | [diff] [blame] | 1706 | time.sleep( main.removeIntentSleep ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1707 | |
kelvin-onlab | 5c706ff | 2015-07-20 10:56:52 -0700 | [diff] [blame] | 1708 | # If there is remianing intents then remove intents should fail |
| 1709 | for i in range( main.numCtrls ): |
| 1710 | onosSummary.append( json.loads( main.CLIs[ i ].summary() ) ) |
| 1711 | |
| 1712 | for summary in onosSummary: |
| 1713 | if summary.get( 'intents' ) != 0: |
| 1714 | main.log.warn( itemName + ": There are " + |
| 1715 | str( summary.get( 'intents' ) ) + |
| 1716 | " intents remaining in node " + |
| 1717 | str( summary.get( 'node' ) ) + |
| 1718 | ", failed to remove all the intents " ) |
| 1719 | removeIntentResult = main.FALSE |
| 1720 | |
| 1721 | if removeIntentResult: |
| 1722 | main.log.info( itemName + ": There are no more intents remaining, " + |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1723 | "successfully removed all the intents." ) |
kelvin-onlab | 5c706ff | 2015-07-20 10:56:52 -0700 | [diff] [blame] | 1724 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1725 | return removeIntentResult |
| 1726 | |
| 1727 | def checkFlowsCount( main ): |
| 1728 | """ |
| 1729 | Check flows count in each node |
| 1730 | """ |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1731 | flowsCount = [] |
| 1732 | main.log.info( itemName + ": Checking flows count in each ONOS node" ) |
| 1733 | for i in range( main.numCtrls ): |
| 1734 | summaryResult = main.CLIs[ i ].summary() |
| 1735 | if not summaryResult: |
| 1736 | main.log.error( itemName + ": There is something wrong with " + |
| 1737 | "summary command" ) |
| 1738 | return main.FALSE |
| 1739 | else: |
| 1740 | summaryJson = json.loads( summaryResult ) |
| 1741 | flowsCount.append( summaryJson.get( 'flows' ) ) |
| 1742 | |
| 1743 | if flowsCount: |
| 1744 | if all( flows==flowsCount[ 0 ] for flows in flowsCount ): |
| 1745 | main.log.info( itemName + ": There are " + str( flowsCount[ 0 ] ) + |
| 1746 | " flows in all ONOS node" ) |
| 1747 | else: |
| 1748 | for i in range( main.numCtrls ): |
| 1749 | main.log.debug( itemName + ": ONOS node " + str( i ) + " has " + |
kelvin-onlab | 6dea6e6 | 2015-07-23 13:07:26 -0700 | [diff] [blame] | 1750 | str( flowsCount[ i ] ) + " flows" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1751 | else: |
| 1752 | main.log.error( "Checking flows count failed, check summary command" ) |
| 1753 | return main.FALSE |
| 1754 | |
| 1755 | return main.TRUE |
| 1756 | |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 1757 | def checkLeaderChange( leaders1, leaders2 ): |
acsmars | e6b410f | 2015-07-17 14:39:34 -0700 | [diff] [blame] | 1758 | """ |
| 1759 | Checks for a change in intent partition leadership. |
| 1760 | |
| 1761 | Takes the output of leaders -c in json string format before and after |
| 1762 | a potential change as input |
| 1763 | |
| 1764 | Returns main.TRUE if no mismatches are detected |
| 1765 | Returns main.FALSE if there is a mismatch or on error loading the input |
| 1766 | """ |
| 1767 | try: |
| 1768 | leaders1 = json.loads( leaders1 ) |
| 1769 | leaders2 = json.loads( leaders2 ) |
| 1770 | except ( AttributeError, TypeError): |
| 1771 | main.log.exception( self.name + ": Object not as expected" ) |
| 1772 | return main.FALSE |
| 1773 | except Exception: |
| 1774 | main.log.exception( self.name + ": Uncaught exception!" ) |
| 1775 | main.cleanup() |
| 1776 | main.exit() |
| 1777 | main.log.info( "Checking Intent Paritions for Change in Leadership" ) |
| 1778 | mismatch = False |
| 1779 | for dict1 in leaders1: |
| 1780 | if "intent" in dict1.get( "topic", [] ): |
| 1781 | for dict2 in leaders2: |
| 1782 | if dict1.get( "topic", 0 ) == dict2.get( "topic", 0 ) and \ |
| 1783 | dict1.get( "leader", 0 ) != dict2.get( "leader", 0 ): |
| 1784 | mismatch = True |
| 1785 | main.log.error( "{0} changed leader from {1} to {2}".\ |
| 1786 | format( dict1.get( "topic", "no-topic" ),\ |
| 1787 | dict1.get( "leader", "no-leader" ),\ |
| 1788 | dict2.get( "leader", "no-leader" ) ) ) |
| 1789 | if mismatch: |
| 1790 | return main.FALSE |
| 1791 | else: |
| 1792 | return main.TRUE |
kelvin-onlab | 016dce2 | 2015-08-10 09:54:11 -0700 | [diff] [blame] | 1793 | |
| 1794 | def report( main ): |
| 1795 | """ |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1796 | Report errors/warnings/exceptions |
kelvin-onlab | 016dce2 | 2015-08-10 09:54:11 -0700 | [diff] [blame] | 1797 | """ |
kelvin-onlab | 016dce2 | 2015-08-10 09:54:11 -0700 | [diff] [blame] | 1798 | main.ONOSbench.logReport( main.ONOSip[ 0 ], |
| 1799 | [ "INFO", |
| 1800 | "FOLLOWER", |
| 1801 | "WARN", |
| 1802 | "flow", |
| 1803 | "ERROR", |
| 1804 | "Except" ], |
| 1805 | "s" ) |
| 1806 | |
| 1807 | main.log.info( "ERROR report: \n" ) |
| 1808 | for i in range( main.numCtrls ): |
| 1809 | main.ONOSbench.logReport( main.ONOSip[ i ], |
| 1810 | [ "ERROR" ], |
| 1811 | "d" ) |
| 1812 | |
| 1813 | main.log.info( "EXCEPTIONS report: \n" ) |
| 1814 | for i in range( main.numCtrls ): |
| 1815 | main.ONOSbench.logReport( main.ONOSip[ i ], |
| 1816 | [ "Except" ], |
| 1817 | "d" ) |
| 1818 | |
| 1819 | main.log.info( "WARNING report: \n" ) |
| 1820 | for i in range( main.numCtrls ): |
| 1821 | main.ONOSbench.logReport( main.ONOSip[ i ], |
| 1822 | [ "WARN" ], |
| 1823 | "d" ) |