kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1 | """ |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 2 | Copyright 2015 Open Networking Foundation ( ONF ) |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 3 | |
| 4 | Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 5 | the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 6 | or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg> |
| 7 | |
| 8 | TestON is free software: you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation, either version 2 of the License, or |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 11 | ( at your option ) any later version. |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 12 | |
| 13 | TestON is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with TestON. If not, see <http://www.gnu.org/licenses/>. |
| 20 | |
| 21 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 22 | Wrapper functions for FuncIntent |
| 23 | This functions include Onosclidriver and Mininetclidriver driver functions |
| 24 | Author: kelvin@onlab.us |
| 25 | """ |
| 26 | import time |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 27 | import json |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 28 | import os |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 29 | |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 30 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 31 | def __init__( self ): |
| 32 | self.default = '' |
| 33 | |
Shreya Chowdhary | 6fbb96c | 2017-05-02 16:20:19 -0700 | [diff] [blame] | 34 | hostIntentFailFlag = False |
| 35 | pointIntentFailFlag = False |
| 36 | singleToMultiFailFlag = False |
| 37 | multiToSingleFailFlag = False |
| 38 | |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 39 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 40 | def installHostIntent( main, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 41 | name, |
| 42 | host1, |
| 43 | host2, |
| 44 | onosNode=0, |
| 45 | ethType="", |
| 46 | bandwidth="", |
| 47 | lambdaAlloc=False, |
| 48 | ipProto="", |
| 49 | ipAddresses="", |
| 50 | tcp="", |
| 51 | sw1="", |
Jeremy Songster | ff55367 | 2016-05-12 17:06:23 -0700 | [diff] [blame] | 52 | sw2="", |
Jeremy Songster | c032f16 | 2016-08-04 17:14:49 -0700 | [diff] [blame] | 53 | setVlan="", |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 54 | encap="" ): |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 55 | """ |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 56 | Installs a Host Intent |
| 57 | |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 58 | Description: |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 59 | Install a host intent using |
| 60 | add-host-intent |
| 61 | |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 62 | Steps: |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 63 | - Fetch host data if not given |
| 64 | - Add host intent |
| 65 | - Ingress device is the first sender host |
| 66 | - Egress devices are the recipient devices |
| 67 | - Ports if defined in senders or recipients |
| 68 | - MAC address ethSrc loaded from Ingress device |
| 69 | - Check intent state with retry |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 70 | Required: |
| 71 | name - Type of point intent to add eg. IPV4 | VLAN | Dualstack |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 72 | host1 - Dictionary for host1 |
| 73 | { "name":"h8", "id":"of:0000000000000005/8" } |
| 74 | host2 - Dictionary for host2 |
| 75 | { "name":"h16", "id":"of:0000000000000006/8" } |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 76 | Optional: |
| 77 | onosNode - ONOS node to install the intents in main.CLIs[ ] |
| 78 | 0 by default so that it will always use the first |
| 79 | ONOS node |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 80 | ethType - Ethernet type eg. IPV4, IPV6 |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 81 | bandwidth - Bandwidth capacity |
| 82 | lambdaAlloc - Allocate lambda, defaults to False |
| 83 | ipProto - IP protocol |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 84 | tcp - TCP ports in the same order as the hosts in hostNames |
| 85 | """ |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 86 | assert main, "There is no main variable" |
| 87 | assert host1, "You must specify host1" |
| 88 | assert host2, "You must specify host2" |
| 89 | |
| 90 | global itemName # The name of this run. Used for logs. |
| 91 | itemName = name |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 92 | |
Shreya Chowdhary | 6fbb96c | 2017-05-02 16:20:19 -0700 | [diff] [blame] | 93 | global hostIntentFailFlag |
| 94 | hostIntentFailFlag = False |
| 95 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 96 | main.log.info( itemName + ": Adding single point to multi point intents" ) |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 97 | try: |
| 98 | if not host1.get( "id" ): |
| 99 | main.log.warn( "ID not given for host1 {0}. Loading from main.hostData".format( host1.get( "name" ) ) ) |
| 100 | main.log.debug( main.hostsData.get( host1.get( "name" ) ) ) |
| 101 | host1[ "id" ] = main.hostsData.get( host1.get( "name" ) ).get( "id" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 102 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 103 | if not host2.get( "id" ): |
| 104 | main.log.warn( "ID not given for host2 {0}. Loading from main.hostData".format( host2.get( "name" ) ) ) |
| 105 | host2[ "id" ] = main.hostsData.get( host2.get( "name" ) ).get( "id" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 106 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 107 | # Adding point intent |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 108 | vlanId = host1.get( "vlan" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 109 | intentId = main.Cluster.active( onosNode ).CLI.addHostIntent( hostIdOne=host1.get( "id" ), |
| 110 | hostIdTwo=host2.get( "id" ), |
| 111 | vlanId=vlanId, |
| 112 | setVlan=setVlan, |
| 113 | encap=encap ) |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 114 | except( KeyError, TypeError ): |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 115 | errorMsg = "There was a problem loading the hosts data." |
| 116 | if intentId: |
| 117 | errorMsg += " There was a problem installing host to host intent." |
| 118 | main.log.error( errorMsg ) |
| 119 | return main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 120 | |
| 121 | # Check intents state |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 122 | if utilities.retry( f=checkIntentState, |
| 123 | retValue=main.FALSE, |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 124 | args=( main, [ intentId ] ), |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 125 | sleep=main.checkIntentSleep, |
| 126 | attempts=50 ): |
Jeremy Songster | 306ed7a | 2016-07-19 10:59:07 -0700 | [diff] [blame] | 127 | main.assertReturnString += 'Install Intent State Passed\n' |
alison | 52b2589 | 2016-09-19 10:53:48 -0700 | [diff] [blame] | 128 | |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 129 | # Check VLAN if test encapsulation |
alison | 52b2589 | 2016-09-19 10:53:48 -0700 | [diff] [blame] | 130 | if encap != "": |
| 131 | if EncapsulatedIntentCheck( main, tag=encap ): |
| 132 | main.assertReturnString += 'Encapsulation intents check Passed\n' |
| 133 | else: |
| 134 | main.assertReturnString += 'Encapsulation intents check failed\n' |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 135 | if bandwidth != "": |
| 136 | allocationsFile = open( os.path.dirname( main.testFile ) + main.params[ 'DEPENDENCY' ][ 'filePath' ], 'r' ) |
| 137 | expectedFormat = allocationsFile.read() |
| 138 | bandwidthCheck = checkBandwidthAllocations( main, expectedFormat ) |
| 139 | allocationsFile.close() |
| 140 | if bandwidthCheck: |
| 141 | main.assertReturnString += 'Bandwidth Allocation check Passed\n' |
| 142 | else: |
| 143 | main.assertReturnString += 'Bandwidth Allocation check Failed\n' |
Jon Hall | c3f88af | 2017-05-23 11:25:54 -0700 | [diff] [blame] | 144 | return main.FALSE |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 145 | |
Jeremy Songster | 306ed7a | 2016-07-19 10:59:07 -0700 | [diff] [blame] | 146 | if flowDuration( main ): |
| 147 | main.assertReturnString += 'Flow duration check Passed\n' |
| 148 | return intentId |
| 149 | else: |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 150 | main.assertReturnString += 'Flow duration check Failed\n' |
Jeremy Songster | 306ed7a | 2016-07-19 10:59:07 -0700 | [diff] [blame] | 151 | return main.FALSE |
alison | 52b2589 | 2016-09-19 10:53:48 -0700 | [diff] [blame] | 152 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 153 | else: |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 154 | main.log.error( "Host Intent did not install correctly" ) |
Shreya Chowdhary | 6fbb96c | 2017-05-02 16:20:19 -0700 | [diff] [blame] | 155 | hostIntentFailFlag = True |
Jeremy Songster | 306ed7a | 2016-07-19 10:59:07 -0700 | [diff] [blame] | 156 | main.assertReturnString += 'Install Intent State Failed\n' |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 157 | return main.FALSE |
| 158 | |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 159 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 160 | def testHostIntent( main, |
| 161 | name, |
| 162 | intentId, |
| 163 | host1, |
| 164 | host2, |
| 165 | onosNode=0, |
| 166 | sw1="s5", |
| 167 | sw2="s2", |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 168 | expectedLink=0 ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 169 | """ |
| 170 | Test a Host Intent |
| 171 | |
| 172 | Description: |
| 173 | Test a host intent of given ID between given hosts |
| 174 | |
| 175 | Steps: |
| 176 | - Fetch host data if not given |
| 177 | - Check Intent State |
| 178 | - Check Flow State |
| 179 | - Check Connectivity |
| 180 | - Check Lack of Connectivity Between Hosts not in the Intent |
| 181 | - Reroute |
| 182 | - Take Expected Link Down |
| 183 | - Check Intent State |
| 184 | - Check Flow State |
| 185 | - Check Topology |
| 186 | - Check Connectivity |
| 187 | - Bring Expected Link Up |
| 188 | - Check Intent State |
| 189 | - Check Flow State |
| 190 | - Check Topology |
| 191 | - Check Connectivity |
| 192 | - Remove Topology |
| 193 | |
| 194 | Required: |
| 195 | name - Type of point intent to add eg. IPV4 | VLAN | Dualstack |
| 196 | intentId - intent ID to be tested ( and removed ) |
| 197 | host1 - Dictionary for host1 |
| 198 | { "name":"h8", "id":"of:0000000000000005/8" } |
| 199 | host2 - Dictionary for host2 |
| 200 | { "name":"h16", "id":"of:0000000000000006/8" } |
| 201 | Optional: |
| 202 | onosNode - ONOS node to install the intents in main.CLIs[ ] |
| 203 | 0 by default so that it will always use the first |
| 204 | ONOS node |
| 205 | sw1 - First switch to bring down & up for rerouting purpose |
| 206 | sw2 - Second switch to bring down & up for rerouting purpose |
| 207 | expectedLink - Expected link when the switches are down, it should |
| 208 | be two links lower than the links before the two |
| 209 | switches are down |
| 210 | |
| 211 | """ |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 212 | # Parameter Validity Check |
| 213 | assert main, "There is no main variable" |
| 214 | assert host1, "You must specify host1" |
| 215 | assert host2, "You must specify host2" |
| 216 | |
| 217 | global itemName |
| 218 | itemName = name |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 219 | |
Shreya Chowdhary | 6fbb96c | 2017-05-02 16:20:19 -0700 | [diff] [blame] | 220 | global hostIntentFailFlag |
| 221 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 222 | main.log.info( itemName + ": Testing Host Intent" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 223 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 224 | try: |
| 225 | if not host1.get( "id" ): |
| 226 | main.log.warn( "Id not given for host1 {0}. Loading from main.hostData".format( host1.get( "name" ) ) ) |
| 227 | host1[ "id" ] = main.hostsData.get( host1.get( "name" ) ).get( "location" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 228 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 229 | if not host2.get( "id" ): |
| 230 | main.log.warn( "Id not given for host2 {0}. Loading from main.hostData".format( host2.get( "name" ) ) ) |
| 231 | host2[ "id" ] = main.hostsData.get( host2.get( "name" ) ).get( "location" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 232 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 233 | senderNames = [ host1.get( "name" ), host2.get( "name" ) ] |
| 234 | recipientNames = [ host1.get( "name" ), host2.get( "name" ) ] |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 235 | vlanId = host1.get( "vlan" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 236 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 237 | testResult = main.TRUE |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 238 | except( KeyError, TypeError ): |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 239 | main.log.error( "There was a problem loading the hosts data." ) |
| 240 | return main.FALSE |
| 241 | |
| 242 | main.log.info( itemName + ": Testing Host to Host intents" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 243 | |
| 244 | # Check intent state |
Shreya Chowdhary | 6fbb96c | 2017-05-02 16:20:19 -0700 | [diff] [blame] | 245 | if hostIntentFailFlag: |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 246 | attempts = main.minimumAttemptsNum |
Shreya Chowdhary | 6fbb96c | 2017-05-02 16:20:19 -0700 | [diff] [blame] | 247 | else: |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 248 | attempts = main.generalAttemptsNum |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 249 | if utilities.retry( f=checkIntentState, |
| 250 | retValue=main.FALSE, |
| 251 | args=( main, [ intentId ] ), |
| 252 | sleep=main.checkIntentSleep, |
| 253 | attempts=attempts ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 254 | main.assertReturnString += 'Initial Intent State Passed\n' |
| 255 | else: |
| 256 | main.assertReturnString += 'Initial Intent State Failed\n' |
| 257 | testResult = main.FALSE |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 258 | attempts = main.minimumAttemptsNum |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 259 | |
| 260 | # Check flows count in each node |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 261 | if utilities.retry( f=checkFlowsCount, |
| 262 | retValue=main.FALSE, |
| 263 | args=[ main ], |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 264 | sleep=main.checkFlowCountSleep, |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 265 | attempts=3 ) and utilities.retry( f=checkFlowsState, |
| 266 | retValue=main.FALSE, |
| 267 | args=[ main ], |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 268 | sleep=main.checkFlowCountSleep, |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 269 | attempts=3 ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 270 | main.assertReturnString += 'Initial Flow State Passed\n' |
| 271 | else: |
| 272 | main.assertReturnString += 'Intial Flow State Failed\n' |
| 273 | testResult = main.FALSE |
| 274 | |
| 275 | # Check Connectivity |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 276 | if utilities.retry( f=scapyCheckConnection, |
| 277 | retValue=main.FALSE, |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 278 | attempts=main.checkConnectionAttNum, |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 279 | sleep=main.checkConnectionSleep, |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 280 | args=( main, senderNames, recipientNames, vlanId ), |
| 281 | getRetryingTime=True ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 282 | main.assertReturnString += 'Initial Ping Passed\n' |
| 283 | else: |
| 284 | main.assertReturnString += 'Initial Ping Failed\n' |
| 285 | testResult = main.FALSE |
| 286 | |
| 287 | # Test rerouting if these variables exist |
| 288 | if sw1 and sw2 and expectedLink: |
| 289 | # Take link down |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 290 | if utilities.retry( f=link, |
| 291 | retValue=main.FALSE, |
| 292 | args=( main, sw1, sw2, "down" ) ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 293 | main.assertReturnString += 'Link Down Passed\n' |
| 294 | else: |
| 295 | main.assertReturnString += 'Link Down Failed\n' |
| 296 | testResult = main.FALSE |
| 297 | |
| 298 | # Check intent state |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 299 | if utilities.retry( f=checkIntentState, |
| 300 | retValue=main.FALSE, |
| 301 | args=( main, [ intentId ] ), |
| 302 | sleep=main.checkIntentHostSleep, |
| 303 | attempts=attempts ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 304 | main.assertReturnString += 'Link Down Intent State Passed\n' |
| 305 | else: |
| 306 | main.assertReturnString += 'Link Down Intent State Failed\n' |
| 307 | testResult = main.FALSE |
| 308 | |
| 309 | # Check flows count in each node |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 310 | if utilities.retry( f=checkFlowsCount, |
| 311 | retValue=main.FALSE, |
| 312 | args=[ main ], |
| 313 | sleep=main.checkFlowCountSleep, |
| 314 | attempts=attempts ) and utilities.retry( f=checkFlowsState, |
| 315 | retValue=main.FALSE, |
| 316 | args=[ main ], |
| 317 | sleep=main.checkFlowCountSleep, |
| 318 | attempts=attempts ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 319 | main.assertReturnString += 'Link Down Flow State Passed\n' |
| 320 | else: |
| 321 | main.assertReturnString += 'Link Down Flow State Failed\n' |
| 322 | testResult = main.FALSE |
| 323 | |
| 324 | # Check OnosTopology |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 325 | if utilities.retry( f=checkTopology, |
| 326 | retValue=main.FALSE, |
| 327 | args=( main, expectedLink ) ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 328 | main.assertReturnString += 'Link Down Topology State Passed\n' |
| 329 | else: |
| 330 | main.assertReturnString += 'Link Down Topology State Failed\n' |
| 331 | testResult = main.FALSE |
| 332 | |
| 333 | # Check Connection |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 334 | if utilities.retry( f=scapyCheckConnection, |
| 335 | retValue=main.FALSE, |
Shreya | ca8990f | 2017-03-16 11:43:11 -0700 | [diff] [blame] | 336 | args=( main, senderNames, recipientNames, vlanId ), |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 337 | sleep=main.checkConnectionSleep, |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 338 | attempts=main.checkConnectionAttNum, |
| 339 | getRetryingTime=True ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 340 | main.assertReturnString += 'Link Down Pingall Passed\n' |
| 341 | else: |
| 342 | main.assertReturnString += 'Link Down Pingall Failed\n' |
| 343 | testResult = main.FALSE |
| 344 | |
| 345 | # Bring link up |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 346 | if utilities.retry( f=link, |
| 347 | retValue=main.FALSE, |
| 348 | args=( main, sw1, sw2, "up" ) ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 349 | main.assertReturnString += 'Link Up Passed\n' |
| 350 | else: |
| 351 | main.assertReturnString += 'Link Up Failed\n' |
| 352 | testResult = main.FALSE |
| 353 | |
| 354 | # Wait for reroute |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 355 | main.log.info( "Sleeping {} seconds".format( main.rerouteSleep ) ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 356 | time.sleep( main.rerouteSleep ) |
| 357 | |
| 358 | # Check Intents |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 359 | if utilities.retry( f=checkIntentState, |
| 360 | retValue=main.FALSE, |
| 361 | attempts=attempts * 2, |
| 362 | args=( main, [ intentId ] ), |
| 363 | sleep=main.checkIntentSleep ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 364 | main.assertReturnString += 'Link Up Intent State Passed\n' |
| 365 | else: |
| 366 | main.assertReturnString += 'Link Up Intent State Failed\n' |
| 367 | testResult = main.FALSE |
| 368 | |
| 369 | # Check flows count in each node |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 370 | if utilities.retry( f=checkFlowsCount, |
| 371 | retValue=main.FALSE, |
| 372 | args=[ main ], |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 373 | sleep=main.checkFlowCountSleep, |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 374 | attempts=3 ) and utilities.retry( f=checkFlowsState, |
| 375 | retValue=main.FALSE, |
| 376 | args=[ main ], |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 377 | sleep=main.checkFlowCountSleep, |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 378 | attempts=3 ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 379 | main.assertReturnString += 'Link Up Flow State Passed\n' |
| 380 | else: |
| 381 | main.assertReturnString += 'Link Up Flow State Failed\n' |
| 382 | testResult = main.FALSE |
| 383 | |
| 384 | # Check OnosTopology |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 385 | if utilities.retry( f=checkTopology, |
| 386 | retValue=main.FALSE, |
| 387 | args=( main, main.numLinks ) ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 388 | main.assertReturnString += 'Link Up Topology State Passed\n' |
| 389 | else: |
| 390 | main.assertReturnString += 'Link Up Topology State Failed\n' |
| 391 | testResult = main.FALSE |
| 392 | |
| 393 | # Check Connection |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 394 | if utilities.retry( f=scapyCheckConnection, |
| 395 | retValue=main.FALSE, |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 396 | args=( main, senderNames, recipientNames, vlanId ), |
| 397 | getRetryingTime=True ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 398 | main.assertReturnString += 'Link Up Pingall Passed\n' |
| 399 | else: |
| 400 | main.assertReturnString += 'Link Up Pingall Failed\n' |
| 401 | testResult = main.FALSE |
| 402 | |
| 403 | # Remove all intents |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 404 | if utilities.retry( f=removeAllIntents, |
| 405 | retValue=main.FALSE, |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 406 | attempts=main.removeIntentAttNum, |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 407 | args=( main, [ intentId ] ) ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 408 | main.assertReturnString += 'Remove Intents Passed' |
| 409 | else: |
| 410 | main.assertReturnString += 'Remove Intents Failed' |
| 411 | testResult = main.FALSE |
| 412 | |
| 413 | return testResult |
| 414 | |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 415 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 416 | def installPointIntent( main, |
| 417 | name, |
| 418 | senders, |
| 419 | recipients, |
| 420 | onosNode=0, |
| 421 | ethType="", |
| 422 | bandwidth="", |
| 423 | lambdaAlloc=False, |
alison | da15727 | 2016-12-22 01:13:21 -0800 | [diff] [blame] | 424 | protected=False, |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 425 | ipProto="", |
| 426 | ipSrc="", |
| 427 | ipDst="", |
| 428 | tcpSrc="", |
Jeremy Songster | ff55367 | 2016-05-12 17:06:23 -0700 | [diff] [blame] | 429 | tcpDst="", |
Jeremy Songster | c032f16 | 2016-08-04 17:14:49 -0700 | [diff] [blame] | 430 | setVlan="", |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 431 | encap="" ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 432 | """ |
| 433 | Installs a Single to Single Point Intent |
| 434 | |
| 435 | Description: |
| 436 | Install a single to single point intent |
| 437 | |
| 438 | Steps: |
| 439 | - Fetch host data if not given |
| 440 | - Add point intent |
| 441 | - Ingress device is the first sender device |
| 442 | - Egress device is the first recipient device |
| 443 | - Ports if defined in senders or recipients |
| 444 | - MAC address ethSrc loaded from Ingress device |
| 445 | - Check intent state with retry |
| 446 | Required: |
| 447 | name - Type of point intent to add eg. IPV4 | VLAN | Dualstack |
| 448 | senders - List of host dictionaries i.e. |
| 449 | [ { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" } ] |
| 450 | recipients - List of host dictionaries i.e. |
| 451 | [ { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" } ] |
| 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 | ethType - Ethernet type eg. IPV4, IPV6 |
| 457 | bandwidth - Bandwidth capacity |
| 458 | lambdaAlloc - Allocate lambda, defaults to False |
| 459 | ipProto - IP protocol |
| 460 | tcp - TCP ports in the same order as the hosts in hostNames |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 461 | sw1 - First switch to bring down & up for rerouting purpose |
| 462 | sw2 - Second switch to bring down & up for rerouting purpose |
| 463 | expectedLink - Expected link when the switches are down, it should |
| 464 | be two links lower than the links before the two |
| 465 | switches are down |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 466 | """ |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 467 | assert main, "There is no main variable" |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 468 | assert senders, "You must specify a sender" |
| 469 | assert recipients, "You must specify a recipient" |
| 470 | # Assert devices or main.hostsData, "You must specify devices" |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 471 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 472 | global itemName # The name of this run. Used for logs. |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 473 | itemName = name |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 474 | |
Shreya Chowdhary | 6fbb96c | 2017-05-02 16:20:19 -0700 | [diff] [blame] | 475 | global pointIntentFailFlag |
| 476 | pointIntentFailFlag = False |
| 477 | |
Jeremy | 6f000c6 | 2016-02-25 17:02:28 -0800 | [diff] [blame] | 478 | main.log.info( itemName + ": Adding point to point intents" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 479 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 480 | try: |
| 481 | for sender in senders: |
| 482 | if not sender.get( "device" ): |
| 483 | main.log.warn( "Device not given for sender {0}. Loading from main.hostData".format( sender.get( "name" ) ) ) |
| 484 | sender[ "device" ] = main.hostsData.get( sender.get( "name" ) ).get( "location" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 485 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 486 | for recipient in recipients: |
| 487 | if not recipient.get( "device" ): |
| 488 | main.log.warn( "Device not given for recipient {0}. Loading from main.hostData".format( recipient.get( "name" ) ) ) |
| 489 | recipient[ "device" ] = main.hostsData.get( recipient.get( "name" ) ).get( "location" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 490 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 491 | ingressDevice = senders[ 0 ].get( "device" ) |
| 492 | egressDevice = recipients[ 0 ].get( "device" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 493 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 494 | portIngress = senders[ 0 ].get( "port", "" ) |
| 495 | portEgress = recipients[ 0 ].get( "port", "" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 496 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 497 | dstMac = recipients[ 0 ].get( "mac" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 498 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 499 | ipSrc = senders[ 0 ].get( "ip" ) |
| 500 | ipDst = recipients[ 0 ].get( "ip" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 501 | |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 502 | vlanId = senders[ 0 ].get( "vlan" ) |
| 503 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 504 | # Adding point intent |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 505 | intentId = main.Cluster.active( onosNode ).CLI.addPointIntent( |
| 506 | ingressDevice=ingressDevice, |
| 507 | egressDevice=egressDevice, |
| 508 | portIngress=portIngress, |
| 509 | portEgress=portEgress, |
| 510 | ethType=ethType, |
| 511 | ethDst=dstMac, |
| 512 | bandwidth=bandwidth, |
| 513 | lambdaAlloc=lambdaAlloc, |
| 514 | protected=protected, |
| 515 | ipProto=ipProto, |
| 516 | ipSrc=ipSrc, |
| 517 | ipDst=ipDst, |
| 518 | tcpSrc=tcpSrc, |
| 519 | tcpDst=tcpDst, |
| 520 | vlanId=vlanId, |
| 521 | setVlan=setVlan, |
| 522 | encap=encap ) |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 523 | except( KeyError, TypeError ): |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 524 | errorMsg = "There was a problem loading the hosts data." |
| 525 | if intentId: |
| 526 | errorMsg += " There was a problem installing Point to Point intent." |
| 527 | main.log.error( errorMsg ) |
| 528 | return main.FALSE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 529 | |
| 530 | # Check intents state |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 531 | if utilities.retry( f=checkIntentState, |
| 532 | retValue=main.FALSE, |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 533 | args=( main, [ intentId ] ), |
| 534 | sleep=main.checkIntentSleep, |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 535 | attempts=50 ): |
Jeremy Songster | 306ed7a | 2016-07-19 10:59:07 -0700 | [diff] [blame] | 536 | main.assertReturnString += 'Install Intent State Passed\n' |
alison | 52b2589 | 2016-09-19 10:53:48 -0700 | [diff] [blame] | 537 | |
Shreya Chowdhary | 6fbb96c | 2017-05-02 16:20:19 -0700 | [diff] [blame] | 538 | if bandwidth != "": |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 539 | allocationsFile = open( os.path.dirname( main.testFile ) + main.params[ 'DEPENDENCY' ][ 'filePath' ], 'r' ) |
| 540 | expectedFormat = allocationsFile.read() |
| 541 | bandwidthCheck = checkBandwidthAllocations( main, expectedFormat ) |
| 542 | allocationsFile.close() |
| 543 | if bandwidthCheck: |
| 544 | main.assertReturnString += 'Bandwidth Allocation check Passed\n' |
| 545 | else: |
| 546 | main.assertReturnString += 'Bandwidth Allocation check Failed\n' |
Jon Hall | c3f88af | 2017-05-23 11:25:54 -0700 | [diff] [blame] | 547 | return main.FALSE |
Shreya Chowdhary | 6fbb96c | 2017-05-02 16:20:19 -0700 | [diff] [blame] | 548 | |
alison | 52b2589 | 2016-09-19 10:53:48 -0700 | [diff] [blame] | 549 | # Check VLAN if test encapsulation |
| 550 | if encap != "": |
| 551 | if EncapsulatedIntentCheck( main, tag=encap ): |
| 552 | main.assertReturnString += 'Encapsulation intents check Passed\n' |
| 553 | else: |
| 554 | main.assertReturnString += 'Encapsulation intents check failed\n' |
alison | da15727 | 2016-12-22 01:13:21 -0800 | [diff] [blame] | 555 | |
Jeremy Songster | 306ed7a | 2016-07-19 10:59:07 -0700 | [diff] [blame] | 556 | if flowDuration( main ): |
| 557 | main.assertReturnString += 'Flow duration check Passed\n' |
| 558 | return intentId |
| 559 | else: |
| 560 | main.assertReturnString += 'Flow duration check failed\n' |
| 561 | return main.FALSE |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 562 | else: |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 563 | main.log.error( "Point Intent did not install correctly" ) |
Shreya Chowdhary | 6fbb96c | 2017-05-02 16:20:19 -0700 | [diff] [blame] | 564 | pointIntentFailFlag = True |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 565 | return main.FALSE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 566 | |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 567 | |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 568 | def pointIntentTcp( main, |
| 569 | name, |
| 570 | host1, |
| 571 | host2, |
| 572 | onosNode=0, |
| 573 | deviceId1="", |
| 574 | deviceId2="", |
| 575 | port1="", |
| 576 | port2="", |
| 577 | ethType="", |
| 578 | mac1="", |
| 579 | mac2="", |
| 580 | bandwidth="", |
| 581 | lambdaAlloc=False, |
| 582 | ipProto="", |
| 583 | ip1="", |
| 584 | ip2="", |
| 585 | tcp1="", |
| 586 | tcp2="", |
| 587 | sw1="", |
| 588 | sw2="", |
| 589 | expectedLink=0 ): |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 590 | """ |
| 591 | Description: |
| 592 | Verify add-point-intent only for TCP |
| 593 | Steps: |
| 594 | - Get device ids | ports |
| 595 | - Add point intents |
| 596 | - Check intents |
| 597 | - Verify flows |
| 598 | - Ping hosts |
| 599 | - Reroute |
| 600 | - Link down |
| 601 | - Verify flows |
| 602 | - Check topology |
| 603 | - Ping hosts |
| 604 | - Link up |
| 605 | - Verify flows |
| 606 | - Check topology |
| 607 | - Ping hosts |
| 608 | - Remove intents |
| 609 | Required: |
| 610 | name - Type of point intent to add eg. IPV4 | VLAN | Dualstack |
| 611 | host1 - Name of first host |
| 612 | host2 - Name of second host |
| 613 | Optional: |
| 614 | onosNode - ONOS node to install the intents in main.CLIs[ ] |
| 615 | 0 by default so that it will always use the first |
| 616 | ONOS node |
| 617 | deviceId1 - ONOS device id of the first switch, the same as the |
| 618 | location of the first host eg. of:0000000000000001/1, |
| 619 | located at device 1 port 1 |
| 620 | deviceId2 - ONOS device id of the second switch |
| 621 | port1 - The port number where the first host is attached |
| 622 | port2 - The port number where the second host is attached |
| 623 | ethType - Ethernet type eg. IPV4, IPV6 |
| 624 | mac1 - Mac address of first host |
| 625 | mac2 - Mac address of the second host |
| 626 | bandwidth - Bandwidth capacity |
| 627 | lambdaAlloc - Allocate lambda, defaults to False |
| 628 | ipProto - IP protocol |
| 629 | ip1 - IP address of first host |
| 630 | ip2 - IP address of second host |
| 631 | tcp1 - TCP port of first host |
| 632 | tcp2 - TCP port of second host |
| 633 | sw1 - First switch to bring down & up for rerouting purpose |
| 634 | sw2 - Second switch to bring down & up for rerouting purpose |
| 635 | expectedLink - Expected link when the switches are down, it should |
| 636 | be two links lower than the links before the two |
| 637 | switches are down |
| 638 | """ |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 639 | assert main, "There is no main variable" |
| 640 | assert name, "variable name is empty" |
| 641 | assert host1 and host2, "You must specify hosts" |
| 642 | |
| 643 | global itemName |
| 644 | itemName = name |
| 645 | host1 = host1 |
| 646 | host2 = host2 |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 647 | intentsId = [] |
| 648 | |
| 649 | iperfResult = main.TRUE |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 650 | linkDownResult = main.TRUE |
| 651 | linkUpResult = main.TRUE |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 652 | |
| 653 | # Adding bidirectional point intents |
| 654 | main.log.info( itemName + ": Adding point intents" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 655 | ctrl = main.Cluster.active( onosNode ) |
| 656 | intent1 = ctrl.CLI.addPointIntent( ingressDevice=deviceId1, |
| 657 | egressDevice=deviceId2, |
| 658 | portIngress=port1, |
| 659 | portEgress=port2, |
| 660 | ethType=ethType, |
| 661 | ethSrc=mac1, |
| 662 | ethDst=mac2, |
| 663 | bandwidth=bandwidth, |
| 664 | lambdaAlloc=lambdaAlloc, |
| 665 | ipProto=ipProto, |
| 666 | ipSrc=ip1, |
| 667 | ipDst=ip2, |
| 668 | tcpSrc=tcp1, |
| 669 | tcpDst="" ) |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 670 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 671 | intent2 = ctrl.CLI.addPointIntent( ingressDevice=deviceId2, |
| 672 | egressDevice=deviceId1, |
| 673 | portIngress=port2, |
| 674 | portEgress=port1, |
| 675 | ethType=ethType, |
| 676 | ethSrc=mac2, |
| 677 | ethDst=mac1, |
| 678 | bandwidth=bandwidth, |
| 679 | lambdaAlloc=lambdaAlloc, |
| 680 | ipProto=ipProto, |
| 681 | ipSrc=ip2, |
| 682 | ipDst=ip1, |
| 683 | tcpSrc=tcp2, |
| 684 | tcpDst="" ) |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 685 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 686 | intent3 = ctrl.CLI.addPointIntent( ingressDevice=deviceId1, |
| 687 | egressDevice=deviceId2, |
| 688 | portIngress=port1, |
| 689 | portEgress=port2, |
| 690 | ethType=ethType, |
| 691 | ethSrc=mac1, |
| 692 | ethDst=mac2, |
| 693 | bandwidth=bandwidth, |
| 694 | lambdaAlloc=lambdaAlloc, |
| 695 | ipProto=ipProto, |
| 696 | ipSrc=ip1, |
| 697 | ipDst=ip2, |
| 698 | tcpSrc="", |
| 699 | tcpDst=tcp2 ) |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 700 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 701 | intent4 = ctrl.CLI.addPointIntent( ingressDevice=deviceId2, |
| 702 | egressDevice=deviceId1, |
| 703 | portIngress=port2, |
| 704 | portEgress=port1, |
| 705 | ethType=ethType, |
| 706 | ethSrc=mac2, |
| 707 | ethDst=mac1, |
| 708 | bandwidth=bandwidth, |
| 709 | lambdaAlloc=lambdaAlloc, |
| 710 | ipProto=ipProto, |
| 711 | ipSrc=ip2, |
| 712 | ipDst=ip1, |
| 713 | tcpSrc="", |
| 714 | tcpDst=tcp1 ) |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 715 | intentsId.append( intent1 ) |
| 716 | intentsId.append( intent2 ) |
| 717 | intentsId.append( intent3 ) |
| 718 | intentsId.append( intent4 ) |
| 719 | |
| 720 | # Check intents state |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 721 | main.log.info( "Sleeping {} seconds".format( main.checkIntentSleep ) ) |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 722 | time.sleep( main.checkIntentSleep ) |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 723 | intentResult = utilities.retry( f=checkIntentState, |
| 724 | retValue=main.FALSE, |
| 725 | args=( main, intentsId ), |
| 726 | sleep=1, |
| 727 | attempts=50 ) |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 728 | # Check flows count in each node |
| 729 | checkFlowsCount( main ) |
| 730 | |
| 731 | # Check intents state again if first check fails... |
| 732 | if not intentResult: |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 733 | intentResult = utilities.retry( f=checkIntentState, |
| 734 | retValue=main.FALSE, |
| 735 | args=( main, intentsId ), |
| 736 | sleep=1, |
| 737 | attempts=50 ) |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 738 | |
| 739 | # Check flows count in each node |
| 740 | checkFlowsCount( main ) |
| 741 | |
| 742 | # Verify flows |
| 743 | checkFlowsState( main ) |
| 744 | |
| 745 | # Run iperf to both host |
You Wang | a0f6ff6 | 2018-01-11 15:46:30 -0800 | [diff] [blame] | 746 | iperfTemp = main.Network.iperftcp( host1, host2, 10 ) |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 747 | iperfResult = iperfResult and iperfTemp |
| 748 | if iperfTemp: |
| 749 | main.assertReturnString += 'Initial Iperf Passed\n' |
| 750 | else: |
| 751 | main.assertReturnString += 'Initial Iperf Failed\n' |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 752 | |
| 753 | # Test rerouting if these variables exist |
| 754 | if sw1 and sw2 and expectedLink: |
| 755 | # link down |
| 756 | linkDownResult = link( main, sw1, sw2, "down" ) |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 757 | |
| 758 | if linkDownResult: |
| 759 | main.assertReturnString += 'Link Down Passed\n' |
| 760 | else: |
| 761 | main.assertReturnString += 'Link Down Failed\n' |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 762 | |
| 763 | # Check flows count in each node |
| 764 | checkFlowsCount( main ) |
| 765 | # Verify flows |
| 766 | checkFlowsState( main ) |
| 767 | |
| 768 | # Check OnosTopology |
| 769 | topoResult = checkTopology( main, expectedLink ) |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 770 | if topoResult: |
| 771 | main.assertReturnString += 'Link Down Topology State Passed\n' |
| 772 | else: |
| 773 | main.assertReturnString += 'Link Down Topology State Failed\n' |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 774 | |
| 775 | # Run iperf to both host |
You Wang | a0f6ff6 | 2018-01-11 15:46:30 -0800 | [diff] [blame] | 776 | iperfTemp = main.Network.iperftcp( host1, host2, 10 ) |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 777 | iperfResult = iperfResult and iperfTemp |
| 778 | if iperfTemp: |
| 779 | main.assertReturnString += 'Link Down Iperf Passed\n' |
| 780 | else: |
| 781 | main.assertReturnString += 'Link Down Iperf Failed\n' |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 782 | |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 783 | # Check intent state |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 784 | intentTemp = utilities.retry( f=checkIntentState, |
| 785 | retValue=main.FALSE, |
| 786 | args=( main, intentsId ), |
| 787 | sleep=1, |
| 788 | attempts=50 ) |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 789 | intentResult = intentResult and intentTemp |
| 790 | if intentTemp: |
| 791 | main.assertReturnString += 'Link Down Intent State Passed\n' |
| 792 | else: |
| 793 | main.assertReturnString += 'Link Down Intent State Failed\n' |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 794 | |
| 795 | # Checks ONOS state in link down |
| 796 | if linkDownResult and topoResult and iperfResult and intentResult: |
| 797 | main.log.info( itemName + ": Successfully brought link down" ) |
| 798 | else: |
| 799 | main.log.error( itemName + ": Failed to bring link down" ) |
| 800 | |
| 801 | # link up |
| 802 | linkUpResult = link( main, sw1, sw2, "up" ) |
alison | 52b2589 | 2016-09-19 10:53:48 -0700 | [diff] [blame] | 803 | if linkUpResult: |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 804 | main.assertReturnString += 'Link Up Passed\n' |
| 805 | else: |
| 806 | main.assertReturnString += 'Link Up Failed\n' |
| 807 | |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 808 | main.log.info( "Sleeping {} seconds".format( main.rerouteSleep ) ) |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 809 | time.sleep( main.rerouteSleep ) |
| 810 | |
| 811 | # Check flows count in each node |
| 812 | checkFlowsCount( main ) |
| 813 | # Verify flows |
| 814 | checkFlowsState( main ) |
| 815 | |
| 816 | # Check OnosTopology |
| 817 | topoResult = checkTopology( main, main.numLinks ) |
| 818 | |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 819 | if topoResult: |
| 820 | main.assertReturnString += 'Link Up Topology State Passed\n' |
| 821 | else: |
| 822 | main.assertReturnString += 'Link Up Topology State Failed\n' |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 823 | |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 824 | # Run iperf to both host |
You Wang | a0f6ff6 | 2018-01-11 15:46:30 -0800 | [diff] [blame] | 825 | iperfTemp = main.Network.iperftcp( host1, host2, 10 ) |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 826 | iperfResult = iperfResult and iperfTemp |
| 827 | if iperfTemp: |
| 828 | main.assertReturnString += 'Link Up Iperf Passed\n' |
| 829 | else: |
| 830 | main.assertReturnString += 'Link Up Iperf Failed\n' |
| 831 | |
| 832 | # Check intent state |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 833 | intentTemp = utilities.retry( f=checkIntentState, |
| 834 | retValue=main.FALSE, |
| 835 | args=( main, intentsId ), |
| 836 | sleep=1, |
| 837 | attempts=50 ) |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 838 | intentResult = intentResult and intentTemp |
| 839 | if intentTemp: |
| 840 | main.assertReturnString += 'Link Down Intent State Passed\n' |
| 841 | else: |
| 842 | main.assertReturnString += 'Link Down Intent State Failed\n' |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 843 | |
| 844 | # Checks ONOS state in link up |
| 845 | if linkUpResult and topoResult and iperfResult and intentResult: |
| 846 | main.log.info( itemName + ": Successfully brought link back up" ) |
| 847 | else: |
| 848 | main.log.error( itemName + ": Failed to bring link back up" ) |
| 849 | |
| 850 | # Remove all intents |
| 851 | removeIntentResult = removeAllIntents( main, intentsId ) |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 852 | if removeIntentResult: |
| 853 | main.assertReturnString += 'Remove Intents Passed' |
| 854 | else: |
| 855 | main.assertReturnString += 'Remove Intents Failed' |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 856 | |
| 857 | stepResult = iperfResult and linkDownResult and linkUpResult \ |
| 858 | and intentResult and removeIntentResult |
| 859 | |
| 860 | return stepResult |
| 861 | |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 862 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 863 | def installSingleToMultiIntent( main, |
| 864 | name, |
| 865 | senders, |
| 866 | recipients, |
| 867 | onosNode=0, |
| 868 | ethType="", |
| 869 | bandwidth="", |
| 870 | lambdaAlloc=False, |
| 871 | ipProto="", |
| 872 | ipAddresses="", |
| 873 | tcp="", |
| 874 | sw1="", |
Jeremy Songster | ff55367 | 2016-05-12 17:06:23 -0700 | [diff] [blame] | 875 | sw2="", |
Jeremy Songster | 9385d41 | 2016-06-02 17:57:36 -0700 | [diff] [blame] | 876 | setVlan="", |
Jeremy Songster | c032f16 | 2016-08-04 17:14:49 -0700 | [diff] [blame] | 877 | partial=False, |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 878 | encap="" ): |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 879 | """ |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 880 | Installs a Single to Multi Point Intent |
| 881 | |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 882 | Description: |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 883 | Install a single to multi point intent using |
| 884 | add-single-to-multi-intent |
| 885 | |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 886 | Steps: |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 887 | - Fetch host data if not given |
| 888 | - Add single to multi intent |
| 889 | - Ingress device is the first sender host |
| 890 | - Egress devices are the recipient devices |
| 891 | - Ports if defined in senders or recipients |
| 892 | - MAC address ethSrc loaded from Ingress device |
| 893 | - Check intent state with retry |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 894 | Required: |
| 895 | name - Type of point intent to add eg. IPV4 | VLAN | Dualstack |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 896 | senders - List of host dictionaries i.e. |
| 897 | { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" } |
| 898 | recipients - List of host dictionaries i.e. |
| 899 | { "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] | 900 | Optional: |
| 901 | onosNode - ONOS node to install the intents in main.CLIs[ ] |
| 902 | 0 by default so that it will always use the first |
| 903 | ONOS node |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 904 | ethType - Ethernet type eg. IPV4, IPV6 |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 905 | bandwidth - Bandwidth capacity |
| 906 | lambdaAlloc - Allocate lambda, defaults to False |
| 907 | ipProto - IP protocol |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 908 | tcp - TCP ports in the same order as the hosts in hostNames |
| 909 | sw1 - First switch to bring down & up for rerouting purpose |
| 910 | sw2 - Second switch to bring down & up for rerouting purpose |
| 911 | expectedLink - Expected link when the switches are down, it should |
| 912 | be two links lower than the links before the two |
| 913 | switches are down |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 914 | """ |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 915 | assert main, "There is no main variable" |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 916 | assert senders, "You must specify a sender" |
| 917 | assert recipients, "You must specify a recipient" |
| 918 | # Assert devices or main.hostsData, "You must specify devices" |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 919 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 920 | global itemName # The name of this run. Used for logs. |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 921 | itemName = name |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 922 | |
Shreya Chowdhary | 6fbb96c | 2017-05-02 16:20:19 -0700 | [diff] [blame] | 923 | global singleToMultiFailFlag |
| 924 | singleToMultiFailFlag = False |
| 925 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 926 | main.log.info( itemName + ": Adding single point to multi point intents" ) |
| 927 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 928 | try: |
| 929 | for sender in senders: |
| 930 | if not sender.get( "device" ): |
| 931 | main.log.warn( "Device not given for sender {0}. Loading from main.hostData".format( sender.get( "name" ) ) ) |
| 932 | sender[ "device" ] = main.hostsData.get( sender.get( "name" ) ).get( "location" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 933 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 934 | for recipient in recipients: |
| 935 | if not recipient.get( "device" ): |
| 936 | main.log.warn( "Device not given for recipient {0}. Loading from main.hostData".format( recipient.get( "name" ) ) ) |
| 937 | recipient[ "device" ] = main.hostsData.get( recipient.get( "name" ) ).get( "location" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 938 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 939 | ingressDevice = senders[ 0 ].get( "device" ) |
| 940 | egressDeviceList = [ x.get( "device" ) for x in recipients if x.get( "device" ) ] |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 941 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 942 | portIngress = senders[ 0 ].get( "port", "" ) |
| 943 | portEgressList = [ x.get( "port" ) for x in recipients if x.get( "port" ) ] |
| 944 | if not portEgressList: |
| 945 | portEgressList = None |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 946 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 947 | srcMac = senders[ 0 ].get( "mac" ) |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 948 | vlanId = senders[ 0 ].get( "vlan" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 949 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 950 | # Adding point intent |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 951 | intentId = main.Cluster.active( onosNode ).CLI.addSinglepointToMultipointIntent( |
| 952 | ingressDevice=ingressDevice, |
| 953 | egressDeviceList=egressDeviceList, |
| 954 | portIngress=portIngress, |
| 955 | portEgressList=portEgressList, |
| 956 | ethType=ethType, |
| 957 | ethSrc=srcMac, |
| 958 | bandwidth=bandwidth, |
| 959 | lambdaAlloc=lambdaAlloc, |
| 960 | ipProto=ipProto, |
| 961 | ipSrc="", |
| 962 | ipDst="", |
| 963 | tcpSrc="", |
| 964 | tcpDst="", |
| 965 | vlanId=vlanId, |
| 966 | setVlan=setVlan, |
| 967 | partial=partial, |
| 968 | encap=encap ) |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 969 | except( KeyError, TypeError ): |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 970 | errorMsg = "There was a problem loading the hosts data." |
| 971 | if intentId: |
| 972 | errorMsg += " There was a problem installing Singlepoint to Multipoint intent." |
| 973 | main.log.error( errorMsg ) |
Shreya Chowdhary | 6fbb96c | 2017-05-02 16:20:19 -0700 | [diff] [blame] | 974 | singleToMultiFailFlag = True |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 975 | return main.FALSE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 976 | |
| 977 | # Check intents state |
Shreya Chowdhary | 6fbb96c | 2017-05-02 16:20:19 -0700 | [diff] [blame] | 978 | if singleToMultiFailFlag: |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 979 | attempts = main.middleAttemptsNum |
Shreya Chowdhary | 6fbb96c | 2017-05-02 16:20:19 -0700 | [diff] [blame] | 980 | else: |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 981 | attempts = main.generalAttemptsNum |
Shreya Chowdhary | 6fbb96c | 2017-05-02 16:20:19 -0700 | [diff] [blame] | 982 | |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 983 | if utilities.retry( f=checkIntentState, |
| 984 | retValue=main.FALSE, |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 985 | args=( main, [ intentId ] ), |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 986 | sleep=main.checkIntentSleep, |
| 987 | attempts=attempts ): |
Jeremy Songster | 306ed7a | 2016-07-19 10:59:07 -0700 | [diff] [blame] | 988 | main.assertReturnString += 'Install Intent State Passed\n' |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 989 | if bandwidth != "": |
| 990 | allocationsFile = open( os.path.dirname( main.testFile ) + main.params[ 'DEPENDENCY' ][ 'filePath' ], 'r' ) |
| 991 | expectedFormat = allocationsFile.read() |
| 992 | bandwidthCheck = checkBandwidthAllocations( main, expectedFormat ) |
| 993 | allocationsFile.close() |
| 994 | if bandwidthCheck: |
| 995 | main.assertReturnString += 'Bandwidth Allocation check Passed\n' |
| 996 | else: |
| 997 | main.assertReturnString += 'Bandwidth Allocation check Failed\n' |
Jon Hall | c3f88af | 2017-05-23 11:25:54 -0700 | [diff] [blame] | 998 | return main.FALSE |
| 999 | |
Jeremy Songster | 306ed7a | 2016-07-19 10:59:07 -0700 | [diff] [blame] | 1000 | if flowDuration( main ): |
| 1001 | main.assertReturnString += 'Flow duration check Passed\n' |
| 1002 | return intentId |
| 1003 | else: |
| 1004 | main.assertReturnString += 'Flow duration check failed\n' |
| 1005 | return main.FALSE |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 1006 | else: |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1007 | main.log.error( "Single to Multi Intent did not install correctly" ) |
Shreya Chowdhary | 6fbb96c | 2017-05-02 16:20:19 -0700 | [diff] [blame] | 1008 | singleToMultiFailFlag = True |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1009 | return main.FALSE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1010 | |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 1011 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1012 | def installMultiToSingleIntent( main, |
| 1013 | name, |
| 1014 | senders, |
| 1015 | recipients, |
| 1016 | onosNode=0, |
| 1017 | ethType="", |
| 1018 | bandwidth="", |
| 1019 | lambdaAlloc=False, |
| 1020 | ipProto="", |
| 1021 | ipAddresses="", |
| 1022 | tcp="", |
| 1023 | sw1="", |
Jeremy Songster | ff55367 | 2016-05-12 17:06:23 -0700 | [diff] [blame] | 1024 | sw2="", |
Jeremy Songster | 9385d41 | 2016-06-02 17:57:36 -0700 | [diff] [blame] | 1025 | setVlan="", |
Jeremy Songster | c032f16 | 2016-08-04 17:14:49 -0700 | [diff] [blame] | 1026 | partial=False, |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 1027 | encap="" ): |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1028 | """ |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1029 | Installs a Multi to Single Point Intent |
| 1030 | |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 1031 | Description: |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1032 | Install a multi to single point intent using |
| 1033 | add-multi-to-single-intent |
| 1034 | |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 1035 | Steps: |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1036 | - Fetch host data if not given |
| 1037 | - Add multi to single intent |
| 1038 | - Ingress devices are the senders devices |
| 1039 | - Egress device is the first recipient host |
| 1040 | - Ports if defined in senders or recipients |
| 1041 | - MAC address ethSrc loaded from Ingress device |
| 1042 | - Check intent state with retry |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 1043 | Required: |
| 1044 | name - Type of point intent to add eg. IPV4 | VLAN | Dualstack |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1045 | senders - List of host dictionaries i.e. |
| 1046 | [ { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" } ] |
| 1047 | recipients - List of host dictionaries i.e. |
| 1048 | [ { "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] | 1049 | Optional: |
| 1050 | onosNode - ONOS node to install the intents in main.CLIs[ ] |
| 1051 | 0 by default so that it will always use the first |
| 1052 | ONOS node |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 1053 | ethType - Ethernet type eg. IPV4, IPV6 |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 1054 | bandwidth - Bandwidth capacity |
| 1055 | lambdaAlloc - Allocate lambda, defaults to False |
| 1056 | ipProto - IP protocol |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 1057 | tcp - TCP ports in the same order as the hosts in hostNames |
| 1058 | sw1 - First switch to bring down & up for rerouting purpose |
| 1059 | sw2 - Second switch to bring down & up for rerouting purpose |
| 1060 | expectedLink - Expected link when the switches are down, it should |
| 1061 | be two links lower than the links before the two |
| 1062 | switches are down |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1063 | """ |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1064 | assert main, "There is no main variable" |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1065 | assert senders, "You must specify a sender" |
| 1066 | assert recipients, "You must specify a recipient" |
| 1067 | # Assert devices or main.hostsData, "You must specify devices" |
| 1068 | |
| 1069 | global itemName # The name of this run. Used for logs. |
| 1070 | itemName = name |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1071 | |
Shreya Chowdhary | 6fbb96c | 2017-05-02 16:20:19 -0700 | [diff] [blame] | 1072 | global multiToSingleFailFlag |
| 1073 | multiToSingleFailFlag = False |
| 1074 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1075 | main.log.info( itemName + ": Adding mutli to single point intents" ) |
| 1076 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1077 | try: |
| 1078 | for sender in senders: |
| 1079 | if not sender.get( "device" ): |
| 1080 | main.log.warn( "Device not given for sender {0}. Loading from main.hostData".format( sender.get( "name" ) ) ) |
| 1081 | sender[ "device" ] = main.hostsData.get( sender.get( "name" ) ).get( "location" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1082 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1083 | for recipient in recipients: |
| 1084 | if not recipient.get( "device" ): |
| 1085 | main.log.warn( "Device not given for recipient {0}. Loading from main.hostData".format( recipient.get( "name" ) ) ) |
| 1086 | recipient[ "device" ] = main.hostsData.get( recipient.get( "name" ) ).get( "location" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1087 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1088 | ingressDeviceList = [ x.get( "device" ) for x in senders if x.get( "device" ) ] |
| 1089 | egressDevice = recipients[ 0 ].get( "device" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1090 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1091 | portIngressList = [ x.get( "port" ) for x in senders if x.get( "port" ) ] |
| 1092 | portEgress = recipients[ 0 ].get( "port", "" ) |
| 1093 | if not portIngressList: |
| 1094 | portIngressList = None |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1095 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1096 | dstMac = recipients[ 0 ].get( "mac" ) |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 1097 | vlanId = senders[ 0 ].get( "vlan" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1098 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1099 | # Adding point intent |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 1100 | intentId = main.Cluster.active( onosNode ).CLI.addMultipointToSinglepointIntent( |
| 1101 | ingressDeviceList=ingressDeviceList, |
| 1102 | egressDevice=egressDevice, |
| 1103 | portIngressList=portIngressList, |
| 1104 | portEgress=portEgress, |
| 1105 | ethType=ethType, |
| 1106 | ethDst=dstMac, |
| 1107 | bandwidth=bandwidth, |
| 1108 | lambdaAlloc=lambdaAlloc, |
| 1109 | ipProto=ipProto, |
| 1110 | ipSrc="", |
| 1111 | ipDst="", |
| 1112 | tcpSrc="", |
| 1113 | tcpDst="", |
| 1114 | vlanId=vlanId, |
| 1115 | setVlan=setVlan, |
| 1116 | partial=partial, |
| 1117 | encap=encap ) |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 1118 | except( KeyError, TypeError ): |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1119 | errorMsg = "There was a problem loading the hosts data." |
| 1120 | if intentId: |
| 1121 | errorMsg += " There was a problem installing Multipoint to Singlepoint intent." |
| 1122 | main.log.error( errorMsg ) |
Shreya Chowdhary | 6fbb96c | 2017-05-02 16:20:19 -0700 | [diff] [blame] | 1123 | multiToSingleFailFlag = True |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1124 | return main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1125 | |
| 1126 | # Check intents state |
Shreya Chowdhary | 6fbb96c | 2017-05-02 16:20:19 -0700 | [diff] [blame] | 1127 | if multiToSingleFailFlag: |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 1128 | attempts = main.middleAttemptsNum |
Shreya Chowdhary | 6fbb96c | 2017-05-02 16:20:19 -0700 | [diff] [blame] | 1129 | else: |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 1130 | attempts = main.generalAttemptsNum |
Shreya Chowdhary | 6fbb96c | 2017-05-02 16:20:19 -0700 | [diff] [blame] | 1131 | |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1132 | if utilities.retry( f=checkIntentState, |
| 1133 | retValue=main.FALSE, |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 1134 | args=( main, [ intentId ] ), |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1135 | sleep=main.checkIntentSleep, |
| 1136 | attempts=attempts ): |
Jeremy Songster | 306ed7a | 2016-07-19 10:59:07 -0700 | [diff] [blame] | 1137 | main.assertReturnString += 'Install Intent State Passed\n' |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 1138 | if bandwidth != "": |
| 1139 | allocationsFile = open( os.path.dirname( main.testFile ) + main.params[ 'DEPENDENCY' ][ 'filePath' ], 'r' ) |
| 1140 | expectedFormat = allocationsFile.read() |
| 1141 | bandwidthCheck = checkBandwidthAllocations( main, expectedFormat ) |
| 1142 | allocationsFile.close() |
| 1143 | if bandwidthCheck: |
| 1144 | main.assertReturnString += 'Bandwidth Allocation check Passed\n' |
| 1145 | else: |
| 1146 | main.assertReturnString += 'Bandwidth Allocation check Failed\n' |
Jon Hall | c3f88af | 2017-05-23 11:25:54 -0700 | [diff] [blame] | 1147 | return main.FALSE |
| 1148 | |
Jeremy Songster | 306ed7a | 2016-07-19 10:59:07 -0700 | [diff] [blame] | 1149 | if flowDuration( main ): |
| 1150 | main.assertReturnString += 'Flow duration check Passed\n' |
| 1151 | return intentId |
| 1152 | else: |
| 1153 | main.assertReturnString += 'Flow duration check failed\n' |
| 1154 | return main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1155 | else: |
| 1156 | main.log.error( "Multi to Single Intent did not install correctly" ) |
Shreya Chowdhary | 6fbb96c | 2017-05-02 16:20:19 -0700 | [diff] [blame] | 1157 | multiToSingleFailFlag = True |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1158 | return main.FALSE |
| 1159 | |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 1160 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1161 | def testPointIntent( main, |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1162 | name, |
| 1163 | intentId, |
| 1164 | senders, |
| 1165 | recipients, |
| 1166 | badSenders={}, |
| 1167 | badRecipients={}, |
| 1168 | onosNode=0, |
| 1169 | ethType="", |
| 1170 | bandwidth="", |
| 1171 | lambdaAlloc=False, |
alison | da15727 | 2016-12-22 01:13:21 -0800 | [diff] [blame] | 1172 | protected=False, |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1173 | ipProto="", |
| 1174 | ipAddresses="", |
| 1175 | tcp="", |
| 1176 | sw1="s5", |
| 1177 | sw2="s2", |
Jeremy Songster | e405d3d | 2016-05-17 11:18:57 -0700 | [diff] [blame] | 1178 | expectedLink=0, |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 1179 | useTCP=False ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1180 | """ |
| 1181 | Test a Point Intent |
| 1182 | |
| 1183 | Description: |
| 1184 | Test a point intent |
| 1185 | |
| 1186 | Steps: |
| 1187 | - Fetch host data if not given |
| 1188 | - Check Intent State |
| 1189 | - Check Flow State |
| 1190 | - Check Connectivity |
| 1191 | - Check Lack of Connectivity Between Hosts not in the Intent |
| 1192 | - Reroute |
| 1193 | - Take Expected Link Down |
| 1194 | - Check Intent State |
| 1195 | - Check Flow State |
| 1196 | - Check Topology |
| 1197 | - Check Connectivity |
| 1198 | - Bring Expected Link Up |
| 1199 | - Check Intent State |
| 1200 | - Check Flow State |
| 1201 | - Check Topology |
| 1202 | - Check Connectivity |
| 1203 | - Remove Topology |
| 1204 | |
| 1205 | Required: |
| 1206 | name - Type of point intent to add eg. IPV4 | VLAN | Dualstack |
| 1207 | |
| 1208 | senders - List of host dictionaries i.e. |
| 1209 | { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" } |
| 1210 | recipients - List of host dictionaries i.e. |
| 1211 | { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" } |
| 1212 | Optional: |
| 1213 | onosNode - ONOS node to install the intents in main.CLIs[ ] |
| 1214 | 0 by default so that it will always use the first |
| 1215 | ONOS node |
| 1216 | ethType - Ethernet type eg. IPV4, IPV6 |
| 1217 | bandwidth - Bandwidth capacity |
| 1218 | lambdaAlloc - Allocate lambda, defaults to False |
| 1219 | ipProto - IP protocol |
| 1220 | tcp - TCP ports in the same order as the hosts in hostNames |
| 1221 | sw1 - First switch to bring down & up for rerouting purpose |
| 1222 | sw2 - Second switch to bring down & up for rerouting purpose |
| 1223 | expectedLink - Expected link when the switches are down, it should |
| 1224 | be two links lower than the links before the two |
| 1225 | switches are down |
| 1226 | |
| 1227 | """ |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1228 | # Parameter Validity Check |
| 1229 | assert main, "There is no main variable" |
| 1230 | assert senders, "You must specify a sender" |
| 1231 | assert recipients, "You must specify a recipient" |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1232 | |
| 1233 | global itemName |
| 1234 | itemName = name |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1235 | |
Shreya Chowdhary | 6fbb96c | 2017-05-02 16:20:19 -0700 | [diff] [blame] | 1236 | global pointIntentFailFlag |
| 1237 | global singleToMultiFailFlag |
| 1238 | global multiToSingleFailFlag |
| 1239 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1240 | main.log.info( itemName + ": Testing Point Intent" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1241 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1242 | try: |
| 1243 | # Names for scapy |
| 1244 | senderNames = [ x.get( "name" ) for x in senders ] |
| 1245 | recipientNames = [ x.get( "name" ) for x in recipients ] |
| 1246 | badSenderNames = [ x.get( "name" ) for x in badSenders ] |
| 1247 | badRecipientNames = [ x.get( "name" ) for x in badRecipients ] |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1248 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1249 | for sender in senders: |
| 1250 | if not sender.get( "device" ): |
| 1251 | main.log.warn( "Device not given for sender {0}. Loading from main.hostData".format( sender.get( "name" ) ) ) |
| 1252 | sender[ "device" ] = main.hostsData.get( sender.get( "name" ) ).get( "location" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1253 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1254 | for recipient in recipients: |
| 1255 | if not recipient.get( "device" ): |
| 1256 | main.log.warn( "Device not given for recipient {0}. Loading from main.hostData".format( recipient.get( "name" ) ) ) |
| 1257 | recipient[ "device" ] = main.hostsData.get( recipient.get( "name" ) ).get( "location" ) |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 1258 | vlanId = senders[ 0 ].get( "vlan" ) |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 1259 | except( KeyError, TypeError ): |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1260 | main.log.error( "There was a problem loading the hosts data." ) |
| 1261 | return main.FALSE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1262 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1263 | testResult = main.TRUE |
| 1264 | main.log.info( itemName + ": Adding single point to multi point intents" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1265 | |
Shreya Chowdhary | 6fbb96c | 2017-05-02 16:20:19 -0700 | [diff] [blame] | 1266 | if pointIntentFailFlag or singleToMultiFailFlag or multiToSingleFailFlag: |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 1267 | attempts = main.minimumAttemptsNum |
Shreya Chowdhary | 6fbb96c | 2017-05-02 16:20:19 -0700 | [diff] [blame] | 1268 | else: |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 1269 | attempts = main.generalAttemptsNum |
Shreya Chowdhary | 6fbb96c | 2017-05-02 16:20:19 -0700 | [diff] [blame] | 1270 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1271 | # Check intent state |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1272 | if utilities.retry( f=checkIntentState, |
| 1273 | retValue=main.FALSE, |
| 1274 | args=( main, [ intentId ] ), |
| 1275 | sleep=main.checkIntentSleep, |
| 1276 | attempts=attempts ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1277 | main.assertReturnString += 'Initial Intent State Passed\n' |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 1278 | else: |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1279 | main.assertReturnString += 'Initial Intent State Failed\n' |
| 1280 | testResult = main.FALSE |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 1281 | attempts = main.minimumAttemptsNum |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1282 | |
| 1283 | # Check flows count in each node |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1284 | if utilities.retry( f=checkFlowsCount, |
| 1285 | retValue=main.FALSE, |
| 1286 | args=[ main ], |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 1287 | sleep=main.checkFlowCountSleep, |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 1288 | attempts=attempts ) and utilities.retry( f=checkFlowsState, |
| 1289 | retValue=main.FALSE, |
| 1290 | args=[ main ], |
| 1291 | sleep=main.checkFlowCountSleep, |
| 1292 | attempts=attempts ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1293 | main.assertReturnString += 'Initial Flow State Passed\n' |
| 1294 | else: |
| 1295 | main.assertReturnString += 'Intial Flow State Failed\n' |
| 1296 | testResult = main.FALSE |
| 1297 | |
| 1298 | # Check Connectivity |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1299 | if utilities.retry( f=scapyCheckConnection, |
| 1300 | retValue=main.FALSE, |
Shreya | ca8990f | 2017-03-16 11:43:11 -0700 | [diff] [blame] | 1301 | args=( main, senderNames, recipientNames, vlanId, useTCP ), |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 1302 | attempts=main.checkConnectionAttNum, |
| 1303 | sleep=main.checkConnectionSleep, |
| 1304 | getRetryingTime=True ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1305 | main.assertReturnString += 'Initial Ping Passed\n' |
| 1306 | else: |
| 1307 | main.assertReturnString += 'Initial Ping Failed\n' |
| 1308 | testResult = main.FALSE |
| 1309 | |
| 1310 | # Check connections that shouldn't work |
| 1311 | if badSenderNames: |
| 1312 | main.log.info( "Checking that packets from incorrect sender do not go through" ) |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1313 | if utilities.retry( f=scapyCheckConnection, |
| 1314 | retValue=main.FALSE, |
| 1315 | args=( main, badSenderNames, recipientNames ), |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 1316 | kwargs={ "expectFailure": True }, |
| 1317 | getRetryingTime=True ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1318 | main.assertReturnString += 'Bad Sender Ping Passed\n' |
| 1319 | else: |
| 1320 | main.assertReturnString += 'Bad Sender Ping Failed\n' |
| 1321 | testResult = main.FALSE |
| 1322 | |
| 1323 | if badRecipientNames: |
| 1324 | main.log.info( "Checking that packets to incorrect recipients do not go through" ) |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1325 | if utilities.retry( f=scapyCheckConnection, |
| 1326 | retValue=main.FALSE, |
| 1327 | args=( main, senderNames, badRecipientNames ), |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 1328 | kwargs={ "expectFailure": True }, |
| 1329 | getRetryingTime=True ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1330 | main.assertReturnString += 'Bad Recipient Ping Passed\n' |
| 1331 | else: |
| 1332 | main.assertReturnString += 'Bad Recipient Ping Failed\n' |
| 1333 | testResult = main.FALSE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1334 | |
| 1335 | # Test rerouting if these variables exist |
| 1336 | if sw1 and sw2 and expectedLink: |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1337 | # Take link down |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1338 | if utilities.retry( f=link, |
| 1339 | retValue=main.FALSE, |
| 1340 | args=( main, sw1, sw2, "down" ) ): |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 1341 | main.assertReturnString += 'Link Down Passed\n' |
| 1342 | else: |
| 1343 | main.assertReturnString += 'Link Down Failed\n' |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1344 | testResult = main.FALSE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1345 | |
alison | da15727 | 2016-12-22 01:13:21 -0800 | [diff] [blame] | 1346 | if protected: |
| 1347 | # Check Connection |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1348 | if utilities.retry( f=scapyCheckConnection, |
| 1349 | retValue=main.FALSE, |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 1350 | args=( main, senderNames, recipientNames, vlanId, useTCP ), |
| 1351 | getRetryingTime=True ): |
alison | da15727 | 2016-12-22 01:13:21 -0800 | [diff] [blame] | 1352 | main.assertReturnString += 'Link down Scapy Packet Received Passed\n' |
| 1353 | else: |
| 1354 | main.assertReturnString += 'Link down Scapy Packet Recieved Failed\n' |
| 1355 | testResult = main.FALSE |
| 1356 | |
| 1357 | if ProtectedIntentCheck( main ): |
| 1358 | main.assertReturnString += 'Protected Intent Check Passed\n' |
| 1359 | else: |
| 1360 | main.assertReturnString += 'Protected Intent Check Failed\n' |
| 1361 | testResult = main.FALSE |
| 1362 | |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 1363 | # Check intent state |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1364 | if utilities.retry( f=checkIntentState, |
| 1365 | retValue=main.FALSE, |
| 1366 | args=( main, [ intentId ] ), |
| 1367 | sleep=main.checkIntentPointSleep, |
| 1368 | attempts=attempts ): |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 1369 | main.assertReturnString += 'Link Down Intent State Passed\n' |
| 1370 | else: |
| 1371 | main.assertReturnString += 'Link Down Intent State Failed\n' |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1372 | testResult = main.FALSE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1373 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1374 | # Check flows count in each node |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1375 | if utilities.retry( f=checkFlowsCount, |
| 1376 | retValue=main.FALSE, |
| 1377 | args=[ main ], |
| 1378 | sleep=main.checkFlowCountSleep, |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 1379 | attempts=attempts ) and utilities.retry( f=checkFlowsState, |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1380 | retValue=main.FALSE, |
| 1381 | args=[ main ], |
| 1382 | sleep=main.checkFlowCountSleep, |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 1383 | attempts=attempts ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1384 | main.assertReturnString += 'Link Down Flow State Passed\n' |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1385 | else: |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1386 | main.assertReturnString += 'Link Down Flow State Failed\n' |
| 1387 | testResult = main.FALSE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1388 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1389 | # Check OnosTopology |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1390 | if utilities.retry( f=checkTopology, |
| 1391 | retValue=main.FALSE, |
| 1392 | args=( main, expectedLink ) ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1393 | main.assertReturnString += 'Link Down Topology State Passed\n' |
| 1394 | else: |
| 1395 | main.assertReturnString += 'Link Down Topology State Failed\n' |
| 1396 | testResult = main.FALSE |
| 1397 | |
| 1398 | # Check Connection |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1399 | if utilities.retry( f=scapyCheckConnection, |
| 1400 | retValue=main.FALSE, |
Shreya | ca8990f | 2017-03-16 11:43:11 -0700 | [diff] [blame] | 1401 | args=( main, senderNames, recipientNames, vlanId, useTCP ), |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1402 | sleep=main.checkConnectionSleep, |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 1403 | attempts=main.checkConnectionAttNum, |
| 1404 | getRetryingTime=True ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1405 | main.assertReturnString += 'Link Down Pingall Passed\n' |
| 1406 | else: |
| 1407 | main.assertReturnString += 'Link Down Pingall Failed\n' |
| 1408 | testResult = main.FALSE |
| 1409 | |
| 1410 | # Bring link up |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1411 | if utilities.retry( f=link, |
| 1412 | retValue=main.FALSE, |
| 1413 | args=( main, sw1, sw2, "up" ) ): |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 1414 | main.assertReturnString += 'Link Up Passed\n' |
| 1415 | else: |
| 1416 | main.assertReturnString += 'Link Up Failed\n' |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1417 | testResult = main.FALSE |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 1418 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1419 | # Wait for reroute |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 1420 | main.log.info( "Sleeping {} seconds".format( main.rerouteSleep ) ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1421 | time.sleep( main.rerouteSleep ) |
| 1422 | |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 1423 | # Check Intents |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1424 | if utilities.retry( f=checkIntentState, |
| 1425 | retValue=main.FALSE, |
| 1426 | attempts=attempts * 2, |
| 1427 | args=( main, [ intentId ] ), |
Shreya | ca8990f | 2017-03-16 11:43:11 -0700 | [diff] [blame] | 1428 | sleep=main.checkIntentSleep ): |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 1429 | main.assertReturnString += 'Link Up Intent State Passed\n' |
| 1430 | else: |
| 1431 | main.assertReturnString += 'Link Up Intent State Failed\n' |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1432 | testResult = main.FALSE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1433 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1434 | # Check flows count in each node |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1435 | if utilities.retry( f=checkFlowsCount, |
| 1436 | retValue=main.FALSE, |
| 1437 | args=[ main ], |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 1438 | sleep=main.checkFlowCountSleep, |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 1439 | attempts=attempts ) and utilities.retry( f=checkFlowsState, |
| 1440 | retValue=main.FALSE, |
| 1441 | args=[ main ], |
| 1442 | sleep=main.checkFlowCountSleep, |
| 1443 | attempts=attempts ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1444 | main.assertReturnString += 'Link Up Flow State Passed\n' |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1445 | else: |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1446 | main.assertReturnString += 'Link Up Flow State Failed\n' |
| 1447 | testResult = main.FALSE |
| 1448 | |
| 1449 | # Check OnosTopology |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1450 | if utilities.retry( f=checkTopology, |
| 1451 | retValue=main.FALSE, |
| 1452 | args=( main, main.numLinks ) ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1453 | main.assertReturnString += 'Link Up Topology State Passed\n' |
| 1454 | else: |
| 1455 | main.assertReturnString += 'Link Up Topology State Failed\n' |
| 1456 | testResult = main.FALSE |
| 1457 | |
| 1458 | # Check Connection |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1459 | if utilities.retry( f=scapyCheckConnection, |
| 1460 | retValue=main.FALSE, |
| 1461 | sleep=main.checkConnectionSleep, |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 1462 | attempts=main.checkConnectionAttNum, |
| 1463 | args=( main, senderNames, recipientNames, vlanId, useTCP ), |
| 1464 | getRetryingTime=True ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1465 | main.assertReturnString += 'Link Up Scapy Packet Received Passed\n' |
| 1466 | else: |
| 1467 | main.assertReturnString += 'Link Up Scapy Packet Recieved Failed\n' |
| 1468 | testResult = main.FALSE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1469 | |
| 1470 | # Remove all intents |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1471 | if utilities.retry( f=removeAllIntents, |
| 1472 | retValue=main.FALSE, |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 1473 | attempts=main.removeIntentAttNum, |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1474 | args=( main, [ intentId ] ) ): |
acsmars | d4862d1 | 2015-10-06 17:57:34 -0700 | [diff] [blame] | 1475 | main.assertReturnString += 'Remove Intents Passed' |
| 1476 | else: |
| 1477 | main.assertReturnString += 'Remove Intents Failed' |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1478 | testResult = main.FALSE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1479 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1480 | return testResult |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1481 | |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 1482 | |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1483 | def testEndPointFail( main, |
| 1484 | name, |
| 1485 | intentId, |
| 1486 | senders, |
| 1487 | recipients, |
| 1488 | isolatedSenders, |
| 1489 | isolatedRecipients, |
| 1490 | onosNode=0, |
| 1491 | ethType="", |
| 1492 | bandwidth="", |
| 1493 | lambdaAlloc=False, |
| 1494 | ipProto="", |
| 1495 | ipAddresses="", |
| 1496 | tcp="", |
| 1497 | sw1="", |
| 1498 | sw2="", |
| 1499 | sw3="", |
| 1500 | sw4="", |
| 1501 | sw5="", |
| 1502 | expectedLink1=0, |
Jeremy Songster | 9385d41 | 2016-06-02 17:57:36 -0700 | [diff] [blame] | 1503 | expectedLink2=0, |
| 1504 | partial=False ): |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1505 | """ |
Shreya | ca8990f | 2017-03-16 11:43:11 -0700 | [diff] [blame] | 1506 | Test Multi point to single point intent Topology for Endpoint failures |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1507 | """ |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1508 | # Parameter Validity Check |
| 1509 | assert main, "There is no main variable" |
| 1510 | assert senders, "You must specify a sender" |
| 1511 | assert recipients, "You must specify a recipient" |
| 1512 | |
| 1513 | global itemName |
| 1514 | itemName = name |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1515 | |
Shreya Chowdhary | 6fbb96c | 2017-05-02 16:20:19 -0700 | [diff] [blame] | 1516 | global singleToMultiFailFlag |
| 1517 | global multiToSingleFailFlag |
| 1518 | |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1519 | main.log.info( itemName + ": Testing Point Intent" ) |
| 1520 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1521 | try: |
| 1522 | # Names for scapy |
| 1523 | senderNames = [ x.get( "name" ) for x in senders ] |
| 1524 | recipientNames = [ x.get( "name" ) for x in recipients ] |
| 1525 | isolatedSenderNames = [ x.get( "name" ) for x in isolatedSenders ] |
| 1526 | isolatedRecipientNames = [ x.get( "name" ) for x in isolatedRecipients ] |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 1527 | connectedSenderNames = [ x.get( "name" ) for x in senders if x.get( "name" ) not in isolatedSenderNames ] |
| 1528 | 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] | 1529 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1530 | for sender in senders: |
| 1531 | if not sender.get( "device" ): |
| 1532 | main.log.warn( "Device not given for sender {0}. Loading from main.hostData".format( sender.get( "name" ) ) ) |
| 1533 | sender[ "device" ] = main.hostsData.get( sender.get( "name" ) ).get( "location" ) |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1534 | |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1535 | for recipient in recipients: |
| 1536 | if not recipient.get( "device" ): |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 1537 | main.log.warn( "Device not given for recipient {0}. Loading from " + |
Jeremy Songster | 306ed7a | 2016-07-19 10:59:07 -0700 | [diff] [blame] | 1538 | main.hostData.format( recipient.get( "name" ) ) ) |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1539 | recipient[ "device" ] = main.hostsData.get( recipient.get( "name" ) ).get( "location" ) |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 1540 | except( KeyError, TypeError ): |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1541 | main.log.error( "There was a problem loading the hosts data." ) |
| 1542 | return main.FALSE |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1543 | |
| 1544 | testResult = main.TRUE |
| 1545 | main.log.info( itemName + ": Adding multi point to single point intents" ) |
| 1546 | |
| 1547 | # Check intent state |
Shreya Chowdhary | 6fbb96c | 2017-05-02 16:20:19 -0700 | [diff] [blame] | 1548 | if singleToMultiFailFlag or multiToSingleFailFlag: |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 1549 | attempts = main.minimumAttemptsNum |
Shreya Chowdhary | 6fbb96c | 2017-05-02 16:20:19 -0700 | [diff] [blame] | 1550 | else: |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 1551 | attempts = main.generalAttemptsNum |
Shreya Chowdhary | 6fbb96c | 2017-05-02 16:20:19 -0700 | [diff] [blame] | 1552 | |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1553 | if utilities.retry( f=checkIntentState, |
| 1554 | retValue=main.FALSE, |
| 1555 | args=( main, [ intentId ] ), |
| 1556 | sleep=main.checkIntentSleep, |
| 1557 | attempts=attempts ): |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1558 | main.assertReturnString += 'Initial Intent State Passed\n' |
| 1559 | else: |
| 1560 | main.assertReturnString += 'Initial Intent State Failed\n' |
| 1561 | testResult = main.FALSE |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 1562 | attempts = main.minimumAttemptsNum |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1563 | |
| 1564 | # Check flows count in each node |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1565 | if utilities.retry( f=checkFlowsCount, |
| 1566 | retValue=main.FALSE, |
| 1567 | args=[ main ], |
| 1568 | attempts=5 ) and utilities.retry( f=checkFlowsState, |
| 1569 | retValue=main.FALSE, |
| 1570 | args=[ main ], |
| 1571 | attempts=5 ): |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1572 | main.assertReturnString += 'Initial Flow State Passed\n' |
| 1573 | else: |
| 1574 | main.assertReturnString += 'Intial Flow State Failed\n' |
| 1575 | testResult = main.FALSE |
| 1576 | |
| 1577 | # Check Connectivity |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1578 | if utilities.retry( f=scapyCheckConnection, |
| 1579 | retValue=main.FALSE, |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 1580 | args=( main, senderNames, recipientNames ), |
| 1581 | getRetryingTime=True ): |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1582 | main.assertReturnString += 'Initial Connectivity Check Passed\n' |
| 1583 | else: |
| 1584 | main.assertReturnString += 'Initial Connectivity Check Failed\n' |
| 1585 | testResult = main.FALSE |
| 1586 | |
| 1587 | # Take two links down |
| 1588 | # Take first link down |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1589 | if utilities.retry( f=link, |
| 1590 | retValue=main.FALSE, |
| 1591 | args=( main, sw1, sw2, "down" ) ): |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1592 | main.assertReturnString += 'Link Down Passed\n' |
| 1593 | else: |
| 1594 | main.assertReturnString += 'Link Down Failed\n' |
| 1595 | testResult = main.FALSE |
| 1596 | |
| 1597 | # Take second link down |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1598 | if utilities.retry( f=link, |
| 1599 | retValue=main.FALSE, |
| 1600 | args=( main, sw3, sw4, "down" ) ): |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1601 | main.assertReturnString += 'Link Down Passed\n' |
| 1602 | else: |
| 1603 | main.assertReturnString += 'Link Down Failed\n' |
| 1604 | testResult = main.FALSE |
| 1605 | |
| 1606 | # Check intent state |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1607 | if utilities.retry( f=checkIntentState, |
| 1608 | retValue=main.FALSE, |
| 1609 | attempts=attempts, |
| 1610 | args=( main, [ intentId ] ), |
| 1611 | sleep=main.checkIntentSleep ): |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1612 | main.assertReturnString += 'Link Down Intent State Passed\n' |
| 1613 | else: |
| 1614 | main.assertReturnString += 'Link Down Intent State Failed\n' |
| 1615 | testResult = main.FALSE |
| 1616 | |
| 1617 | # Check flows count in each node |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1618 | if utilities.retry( f=checkFlowsCount, |
| 1619 | retValue=main.FALSE, |
| 1620 | sleep=1, |
| 1621 | attempts=attempts, |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1622 | args=[ main ] ) and utilities.retry( f=checkFlowsState, |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1623 | retValue=main.FALSE, |
| 1624 | sleep=1, |
| 1625 | attempts=attempts, |
| 1626 | args=[ main ] ): |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1627 | main.assertReturnString += 'Link Down Flow State Passed\n' |
| 1628 | else: |
| 1629 | main.assertReturnString += 'Link Down Flow State Failed\n' |
| 1630 | testResult = main.FALSE |
| 1631 | |
| 1632 | # Check OnosTopology |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1633 | if utilities.retry( f=checkTopology, |
| 1634 | retValue=main.FALSE, |
| 1635 | args=( main, expectedLink1 ) ): |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1636 | main.assertReturnString += 'Link Down Topology State Passed\n' |
| 1637 | else: |
| 1638 | main.assertReturnString += 'Link Down Topology State Failed\n' |
| 1639 | testResult = main.FALSE |
| 1640 | |
| 1641 | # Check Connection |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1642 | if utilities.retry( f=scapyCheckConnection, |
| 1643 | retValue=main.FALSE, |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 1644 | args=( main, senderNames, recipientNames ), |
| 1645 | getRetryingTime=True ): |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1646 | main.assertReturnString += 'Link Down Connectivity Check Passed\n' |
| 1647 | else: |
| 1648 | main.assertReturnString += 'Link Down Connectivity Check Failed\n' |
| 1649 | testResult = main.FALSE |
| 1650 | |
| 1651 | # Take a third link down to isolate one node |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1652 | if utilities.retry( f=link, |
| 1653 | retValue=main.FALSE, |
| 1654 | args=( main, sw3, sw5, "down" ) ): |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1655 | main.assertReturnString += 'Isolation link Down Passed\n' |
| 1656 | else: |
| 1657 | main.assertReturnString += 'Isolation link Down Failed\n' |
| 1658 | testResult = main.FALSE |
| 1659 | |
Jeremy Songster | 9385d41 | 2016-06-02 17:57:36 -0700 | [diff] [blame] | 1660 | if partial: |
| 1661 | # Check intent state |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1662 | if utilities.retry( f=checkIntentState, |
| 1663 | retValue=main.FALSE, |
| 1664 | args=( main, [ intentId ] ), |
| 1665 | sleep=main.checkIntentSleep, |
| 1666 | attempts=attempts ): |
Jeremy Songster | 9385d41 | 2016-06-02 17:57:36 -0700 | [diff] [blame] | 1667 | main.assertReturnString += 'Partial failure isolation link Down Intent State Passed\n' |
| 1668 | else: |
| 1669 | main.assertReturnString += 'Partial failure isolation link Down Intent State Failed\n' |
| 1670 | testResult = main.FALSE |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1671 | |
Jeremy Songster | 9385d41 | 2016-06-02 17:57:36 -0700 | [diff] [blame] | 1672 | # Check flows count in each node |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1673 | if utilities.retry( f=checkFlowsCount, |
| 1674 | retValue=main.FALSE, |
| 1675 | args=[ main ], |
| 1676 | attempts=5 ) and utilities.retry( f=checkFlowsState, |
| 1677 | retValue=main.FALSE, |
| 1678 | args=[ main ], |
| 1679 | attempts=5 ): |
Jeremy Songster | 9385d41 | 2016-06-02 17:57:36 -0700 | [diff] [blame] | 1680 | main.assertReturnString += 'Partial failure isolation link Down Flow State Passed\n' |
| 1681 | else: |
| 1682 | main.assertReturnString += 'Partial failure isolation link Down Flow State Failed\n' |
| 1683 | testResult = main.FALSE |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1684 | |
Jeremy Songster | 9385d41 | 2016-06-02 17:57:36 -0700 | [diff] [blame] | 1685 | # Check OnosTopology |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1686 | if utilities.retry( f=checkTopology, |
| 1687 | retValue=main.FALSE, |
| 1688 | args=( main, expectedLink2 ) ): |
Jeremy Songster | 9385d41 | 2016-06-02 17:57:36 -0700 | [diff] [blame] | 1689 | main.assertReturnString += 'Partial failure isolation link Down Topology State Passed\n' |
| 1690 | else: |
| 1691 | main.assertReturnString += 'Partial failure isolation link Down Topology State Failed\n' |
| 1692 | testResult = main.FALSE |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1693 | |
Jeremy Songster | 9385d41 | 2016-06-02 17:57:36 -0700 | [diff] [blame] | 1694 | # Check Connectivity |
| 1695 | # First check connectivity of any isolated senders to recipients |
| 1696 | if isolatedSenderNames: |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1697 | if scapyCheckConnection( main, |
| 1698 | isolatedSenderNames, |
| 1699 | recipientNames, |
| 1700 | None, |
| 1701 | None, |
| 1702 | None, |
| 1703 | None, |
| 1704 | main.TRUE ): |
Jeremy Songster | 9385d41 | 2016-06-02 17:57:36 -0700 | [diff] [blame] | 1705 | main.assertReturnString += 'Partial failure isolation link Down Connectivity Check Passed\n' |
| 1706 | else: |
| 1707 | main.assertReturnString += 'Partial failure isolation link Down Connectivity Check Failed\n' |
| 1708 | testResult = main.FALSE |
| 1709 | |
| 1710 | # Next check connectivity of senders to any isolated recipients |
| 1711 | if isolatedRecipientNames: |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1712 | if scapyCheckConnection( main, |
| 1713 | senderNames, |
| 1714 | isolatedRecipientNames, |
| 1715 | None, |
| 1716 | None, |
| 1717 | None, |
| 1718 | None, |
| 1719 | main.TRUE ): |
Jeremy Songster | 9385d41 | 2016-06-02 17:57:36 -0700 | [diff] [blame] | 1720 | main.assertReturnString += 'Partial failure isolation link Down Connectivity Check Passed\n' |
| 1721 | else: |
| 1722 | main.assertReturnString += 'Partial failure isolation link Down Connectivity Check Failed\n' |
| 1723 | testResult = main.FALSE |
| 1724 | |
| 1725 | # Next check connectivity of connected senders and recipients |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1726 | if utilities.retry( f=scapyCheckConnection, |
| 1727 | retValue=main.FALSE, |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 1728 | attempts=main.checkConnectionAttNum, |
| 1729 | args=( main, connectedSenderNames, connectedRecipientNames ), |
| 1730 | getRetryingTime=True ): |
Jeremy Songster | 9385d41 | 2016-06-02 17:57:36 -0700 | [diff] [blame] | 1731 | main.assertReturnString += 'Partial failure isolation link Down Connectivity Check Passed\n' |
| 1732 | else: |
| 1733 | main.assertReturnString += 'Partial failure isolation link Down Connectivity Check Failed\n' |
| 1734 | testResult = main.FALSE |
| 1735 | else: |
| 1736 | # Check intent state |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1737 | if not utilities.retry( f=checkIntentState, |
| 1738 | retValue=main.TRUE, |
| 1739 | args=( main, [ intentId ] ), |
| 1740 | sleep=main.checkIntentSleep, |
| 1741 | attempts=attempts ): |
Jeremy Songster | 9385d41 | 2016-06-02 17:57:36 -0700 | [diff] [blame] | 1742 | main.assertReturnString += 'Isolation link Down Intent State Passed\n' |
| 1743 | else: |
| 1744 | main.assertReturnString += 'Isolation link Down Intent State Failed\n' |
| 1745 | testResult = main.FALSE |
| 1746 | |
| 1747 | # Check flows count in each node |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1748 | if utilities.retry( f=checkFlowsCount, |
| 1749 | retValue=main.FALSE, |
| 1750 | args=[ main ], |
| 1751 | attempts=5 ) and utilities.retry( f=checkFlowsState, |
| 1752 | retValue=main.FALSE, |
| 1753 | args=[ main ], |
| 1754 | attempts=5 ): |
Jeremy Songster | 9385d41 | 2016-06-02 17:57:36 -0700 | [diff] [blame] | 1755 | main.assertReturnString += 'Isolation link Down Flow State Passed\n' |
| 1756 | else: |
| 1757 | main.assertReturnString += 'Isolation link Down Flow State Failed\n' |
| 1758 | testResult = main.FALSE |
| 1759 | |
| 1760 | # Check OnosTopology |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1761 | if utilities.retry( f=checkTopology, |
| 1762 | retValue=main.FALSE, |
| 1763 | args=( main, expectedLink2 ) ): |
Jeremy Songster | 9385d41 | 2016-06-02 17:57:36 -0700 | [diff] [blame] | 1764 | main.assertReturnString += 'Isolation link Down Topology State Passed\n' |
| 1765 | else: |
| 1766 | main.assertReturnString += 'Isolation link Down Topology State Failed\n' |
| 1767 | testResult = main.FALSE |
| 1768 | |
| 1769 | # Check Connectivity |
| 1770 | # First check connectivity of any isolated senders to recipients |
| 1771 | if isolatedSenderNames: |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1772 | if scapyCheckConnection( main, |
| 1773 | isolatedSenderNames, |
| 1774 | recipientNames, |
| 1775 | None, |
| 1776 | None, |
| 1777 | None, |
| 1778 | None, |
| 1779 | main.TRUE ): |
Jeremy Songster | 9385d41 | 2016-06-02 17:57:36 -0700 | [diff] [blame] | 1780 | main.assertReturnString += 'Isolation link Down Connectivity Check Passed\n' |
| 1781 | else: |
| 1782 | main.assertReturnString += 'Isolation link Down Connectivity Check Failed\n' |
| 1783 | testResult = main.FALSE |
| 1784 | |
| 1785 | # Next check connectivity of senders to any isolated recipients |
| 1786 | if isolatedRecipientNames: |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1787 | if scapyCheckConnection( main, |
| 1788 | senderNames, |
| 1789 | isolatedRecipientNames, |
| 1790 | None, |
| 1791 | None, |
| 1792 | None, |
| 1793 | None, |
| 1794 | main.TRUE ): |
Jeremy Songster | 9385d41 | 2016-06-02 17:57:36 -0700 | [diff] [blame] | 1795 | main.assertReturnString += 'Isolation link Down Connectivity Check Passed\n' |
| 1796 | else: |
| 1797 | main.assertReturnString += 'Isolation link Down Connectivity Check Failed\n' |
| 1798 | testResult = main.FALSE |
| 1799 | |
| 1800 | # Next check connectivity of connected senders and recipients |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1801 | if utilities.retry( f=scapyCheckConnection, |
| 1802 | retValue=main.TRUE, |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 1803 | args=( main, connectedSenderNames, connectedRecipientNames, None, None, None, None, main.TRUE ), |
| 1804 | getRetryingTime=True ): |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1805 | main.assertReturnString += 'Isolation link Down Connectivity Check Passed\n' |
| 1806 | else: |
| 1807 | main.assertReturnString += 'Isolation link Down Connectivity Check Failed\n' |
| 1808 | testResult = main.FALSE |
| 1809 | |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1810 | # Bring the links back up |
| 1811 | # Bring first link up |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1812 | if utilities.retry( f=link, |
| 1813 | retValue=main.FALSE, |
| 1814 | args=( main, sw1, sw2, "up" ) ): |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1815 | main.assertReturnString += 'Link Up Passed\n' |
| 1816 | else: |
| 1817 | main.assertReturnString += 'Link Up Failed\n' |
| 1818 | testResult = main.FALSE |
| 1819 | |
| 1820 | # Bring second link up |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1821 | if utilities.retry( f=link, |
| 1822 | retValue=main.FALSE, |
| 1823 | args=( main, sw3, sw5, "up" ) ): |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1824 | main.assertReturnString += 'Link Up Passed\n' |
| 1825 | else: |
| 1826 | main.assertReturnString += 'Link Up Failed\n' |
| 1827 | testResult = main.FALSE |
| 1828 | |
| 1829 | # Bring third link up |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1830 | if utilities.retry( f=link, |
| 1831 | retValue=main.FALSE, |
| 1832 | args=( main, sw3, sw4, "up" ) ): |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1833 | main.assertReturnString += 'Link Up Passed\n' |
| 1834 | else: |
| 1835 | main.assertReturnString += 'Link Up Failed\n' |
| 1836 | testResult = main.FALSE |
| 1837 | |
| 1838 | # Wait for reroute |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 1839 | main.log.info( "Sleeping {} seconds".format( main.rerouteSleep ) ) |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1840 | time.sleep( main.rerouteSleep ) |
| 1841 | |
| 1842 | # Check Intents |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1843 | if utilities.retry( f=checkIntentState, |
| 1844 | retValue=main.FALSE, |
| 1845 | attempts=attempts, |
| 1846 | args=( main, [ intentId ] ), |
| 1847 | sleep=main.checkIntentHostSleep ): |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1848 | main.assertReturnString += 'Link Up Intent State Passed\n' |
| 1849 | else: |
| 1850 | main.assertReturnString += 'Link Up Intent State Failed\n' |
| 1851 | testResult = main.FALSE |
| 1852 | |
| 1853 | # Check flows count in each node |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1854 | if utilities.retry( f=checkFlowsCount, |
| 1855 | retValue=main.FALSE, |
| 1856 | args=[ main ], |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 1857 | sleep=main.checkFlowCountSleep, |
| 1858 | attempts=attempts ) and utilities.retry( f=checkFlowsState, |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 1859 | retValue=main.FALSE, |
| 1860 | args=[ main ], |
| 1861 | sleep=main.checkFlowCountSleep, |
| 1862 | attempts=attempts ): |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1863 | main.assertReturnString += 'Link Up Flow State Passed\n' |
| 1864 | else: |
| 1865 | main.assertReturnString += 'Link Up Flow State Failed\n' |
| 1866 | testResult = main.FALSE |
| 1867 | |
| 1868 | # Check OnosTopology |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1869 | if utilities.retry( f=checkTopology, |
| 1870 | retValue=main.FALSE, |
| 1871 | args=( main, main.numLinks ) ): |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1872 | main.assertReturnString += 'Link Up Topology State Passed\n' |
| 1873 | else: |
| 1874 | main.assertReturnString += 'Link Up Topology State Failed\n' |
| 1875 | testResult = main.FALSE |
| 1876 | |
| 1877 | # Check Connection |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1878 | if utilities.retry( f=scapyCheckConnection, |
| 1879 | retValue=main.FALSE, |
| 1880 | sleep=main.checkConnectionSleep, |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 1881 | attempts=main.checkConnectionAttNum, |
| 1882 | args=( main, senderNames, recipientNames ), |
| 1883 | getRetryingTime=True ): |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1884 | main.assertReturnString += 'Link Up Scapy Packet Received Passed\n' |
| 1885 | else: |
| 1886 | main.assertReturnString += 'Link Up Scapy Packet Recieved Failed\n' |
| 1887 | testResult = main.FALSE |
| 1888 | |
| 1889 | # Remove all intents |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1890 | if utilities.retry( f=removeAllIntents, |
| 1891 | retValue=main.FALSE, |
Devin Lim | a4f95bc | 2017-08-11 11:13:03 -0700 | [diff] [blame] | 1892 | attempts=main.removeIntentAttNum, |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 1893 | args=( main, [ intentId ] ) ): |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1894 | main.assertReturnString += 'Remove Intents Passed' |
| 1895 | else: |
| 1896 | main.assertReturnString += 'Remove Intents Failed' |
| 1897 | testResult = main.FALSE |
| 1898 | |
| 1899 | return testResult |
| 1900 | |
| 1901 | |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 1902 | def pingallHosts( main, hostList ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1903 | """ |
| 1904 | Ping all host in the hosts list variable |
| 1905 | """ |
Jon Hall | a5cb341 | 2015-08-18 14:08:22 -0700 | [diff] [blame] | 1906 | main.log.info( "Pinging: " + str( hostList ) ) |
You Wang | a0f6ff6 | 2018-01-11 15:46:30 -0800 | [diff] [blame] | 1907 | return main.Network.pingallHosts( hostList ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1908 | |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 1909 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1910 | def fwdPingall( main ): |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1911 | """ |
| 1912 | Use fwd app and pingall to discover all the hosts |
| 1913 | """ |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1914 | appCheck = main.TRUE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1915 | main.log.info( "Activating reactive forwarding app " ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 1916 | activateResult = main.Cluster.active( 0 ).CLI.activateApp( "org.onosproject.fwd" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1917 | |
| 1918 | # Wait for forward app activation to propagate |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 1919 | main.log.info( "Sleeping {} seconds".format( main.fwdSleep ) ) |
kelvin-onlab | 0ad05d1 | 2015-07-23 14:21:15 -0700 | [diff] [blame] | 1920 | time.sleep( main.fwdSleep ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1921 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1922 | # Check that forwarding is enabled on all nodes |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 1923 | for ctrl in main.Cluster.active(): |
| 1924 | appCheck = appCheck and ctrl.CLI.appToIDCheck() |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1925 | if appCheck != main.TRUE: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 1926 | main.log.warn( ctrl.CLI.apps() ) |
| 1927 | main.log.warn( ctrl.CLI.appIDs() ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1928 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1929 | # Send pingall in mininet |
| 1930 | main.log.info( "Run Pingall" ) |
You Wang | a0f6ff6 | 2018-01-11 15:46:30 -0800 | [diff] [blame] | 1931 | pingResult = main.Network.pingall( timeout=600 ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1932 | |
| 1933 | main.log.info( "Deactivating reactive forwarding app " ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 1934 | deactivateResult = main.Cluster.active( 0 ).CLI.deactivateApp( "org.onosproject.fwd" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1935 | if activateResult and deactivateResult: |
| 1936 | main.log.info( "Successfully used fwd app to discover hosts" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1937 | getDataResult = main.TRUE |
| 1938 | else: |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1939 | main.log.info( "Failed to use fwd app to discover hosts" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1940 | getDataResult = main.FALSE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1941 | return getDataResult |
| 1942 | |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 1943 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1944 | def confirmHostDiscovery( main ): |
| 1945 | """ |
| 1946 | Confirms that all ONOS nodes have discovered all scapy hosts |
| 1947 | """ |
| 1948 | import collections |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 1949 | try: |
| 1950 | from tests.dependencies.topology import Topology |
| 1951 | except Exception: |
| 1952 | main.log.error( "Topology not found exiting the test" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 1953 | main.cleanAndExit() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 1954 | try: |
| 1955 | main.topoRelated |
| 1956 | except Exception: |
| 1957 | main.topoRelated = Topology() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 1958 | hosts = main.topoRelated.getAll( "hosts", False ) # Get host data from each ONOS node |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1959 | hostFails = [] # Reset for each failed attempt |
| 1960 | |
| 1961 | # Check for matching hosts on each node |
| 1962 | scapyHostIPs = [ x.hostIp for x in main.scapyHosts if x.hostIp != "0.0.0.0" ] |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 1963 | for controller in range( main.Cluster.numCtrls ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1964 | controllerStr = str( controller + 1 ) # ONOS node number |
| 1965 | # Compare Hosts |
| 1966 | # Load hosts data for controller node |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1967 | try: |
| 1968 | if hosts[ controller ]: |
| 1969 | main.log.info( "Hosts discovered" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1970 | else: |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1971 | main.log.error( "Problem discovering hosts" ) |
| 1972 | if hosts[ controller ] and "Error" not in hosts[ controller ]: |
| 1973 | try: |
| 1974 | hostData = json.loads( hosts[ controller ] ) |
| 1975 | except ( TypeError, ValueError ): |
| 1976 | main.log.error( "Could not load json:" + str( hosts[ controller ] ) ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1977 | hostFails.append( controllerStr ) |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1978 | else: |
| 1979 | onosHostIPs = [ x.get( "ipAddresses" )[ 0 ] |
| 1980 | for x in hostData |
| 1981 | if len( x.get( "ipAddresses" ) ) > 0 ] |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 1982 | if not set( collections.Counter( scapyHostIPs ) ).issubset( |
| 1983 | set( collections.Counter( onosHostIPs ) ) ): |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1984 | main.log.warn( "Controller {0} only sees nodes with {1} IPs. It should see all of the following: {2}".format( controllerStr, onosHostIPs, scapyHostIPs ) ) |
| 1985 | hostFails.append( controllerStr ) |
| 1986 | else: |
| 1987 | main.log.error( "Hosts returned nothing or an error." ) |
| 1988 | hostFails.append( controllerStr ) |
| 1989 | except IndexError: |
| 1990 | main.log.error( "Hosts returned nothing, Failed to discover hosts." ) |
| 1991 | return main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1992 | |
| 1993 | if hostFails: |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 1994 | main.log.error( "List of failed ONOS Nodes:" + ', '.join( map( str, hostFails ) ) ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1995 | return main.FALSE |
| 1996 | else: |
| 1997 | return main.TRUE |
| 1998 | |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 1999 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 2000 | def sendDiscoveryArp( main, hosts=None ): |
| 2001 | """ |
| 2002 | Sends Discovery ARP packets from each host provided |
| 2003 | Defaults to each host in main.scapyHosts |
| 2004 | """ |
| 2005 | # Send an arp ping from each host |
| 2006 | if not hosts: |
| 2007 | hosts = main.scapyHosts |
| 2008 | for host in hosts: |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 2009 | pkt = 'Ether( src="{0}")/ARP( psrc="{1}")'.format( host.hostMac, host.hostIp ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 2010 | # Send from the VLAN interface if there is one so ONOS discovers the VLAN correctly |
| 2011 | iface = None |
| 2012 | for interface in host.getIfList(): |
| 2013 | if '.' in interface: |
| 2014 | main.log.debug( "Detected VLAN interface {0}. Sending ARP packet from {0}".format( interface ) ) |
| 2015 | iface = interface |
| 2016 | break |
| 2017 | host.sendPacket( packet=pkt, iface=iface ) |
| 2018 | main.log.info( "Sending ARP packet from {0}".format( host.name ) ) |
| 2019 | |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 2020 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 2021 | def populateHostData( main ): |
| 2022 | """ |
| 2023 | Populates hostsData |
| 2024 | """ |
| 2025 | import json |
| 2026 | try: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 2027 | hostsJson = json.loads( main.Cluster.active( 0 ).CLI.hosts() ) |
You Wang | a0f6ff6 | 2018-01-11 15:46:30 -0800 | [diff] [blame] | 2028 | hosts = main.Network.getHosts().keys() |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 2029 | # TODO: Make better use of new getHosts function |
| 2030 | for host in hosts: |
| 2031 | main.hostsData[ host ] = {} |
| 2032 | main.hostsData[ host ][ 'mac' ] = \ |
You Wang | a0f6ff6 | 2018-01-11 15:46:30 -0800 | [diff] [blame] | 2033 | main.Network.getMacAddress( host ).upper() |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 2034 | for hostj in hostsJson: |
| 2035 | if main.hostsData[ host ][ 'mac' ] == hostj[ 'mac' ]: |
| 2036 | main.hostsData[ host ][ 'id' ] = hostj[ 'id' ] |
| 2037 | main.hostsData[ host ][ 'vlan' ] = hostj[ 'vlan' ] |
| 2038 | main.hostsData[ host ][ 'location' ] = \ |
Jeremy Ronquillo | 0e538bc | 2017-06-13 15:16:09 -0700 | [diff] [blame] | 2039 | hostj[ 'locations' ][ 0 ][ 'elementId' ] + '/' + \ |
| 2040 | hostj[ 'locations' ][ 0 ][ 'port' ] |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 2041 | main.hostsData[ host ][ 'ipAddresses' ] = hostj[ 'ipAddresses' ] |
| 2042 | return main.TRUE |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 2043 | except ValueError: |
| 2044 | main.log.error( "ValueError while populating hostsData" ) |
| 2045 | return main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 2046 | except KeyError: |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 2047 | main.log.error( "KeyError while populating hostsData" ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 2048 | return main.FALSE |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 2049 | except IndexError: |
| 2050 | main.log.error( "IndexError while populating hostsData" ) |
| 2051 | return main.FALSE |
| 2052 | except TypeError: |
| 2053 | main.log.error( "TypeError while populating hostsData" ) |
| 2054 | return main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 2055 | |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 2056 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 2057 | def checkTopology( main, expectedLink ): |
| 2058 | statusResult = main.TRUE |
| 2059 | # Check onos topology |
| 2060 | main.log.info( itemName + ": Checking ONOS topology " ) |
| 2061 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 2062 | statusResult = main.Cluster.command( "checkStatus", |
| 2063 | args=[ main.numSwitch, expectedLink ], |
| 2064 | returnBool=True, specificDriver=2 ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 2065 | if not statusResult: |
| 2066 | main.log.error( itemName + ": Topology mismatch" ) |
| 2067 | else: |
| 2068 | main.log.info( itemName + ": Topology match" ) |
| 2069 | return statusResult |
| 2070 | |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 2071 | |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 2072 | def checkIntentState( main, intentsId ): |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 2073 | """ |
| 2074 | This function will check intent state to make sure all the intents |
| 2075 | are in INSTALLED state |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 2076 | Returns main.TRUE or main.FALSE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 2077 | """ |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 2078 | intentResult = main.TRUE |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 2079 | stateCheckResults = main.Cluster.command( "checkIntentState", |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 2080 | kwargs={ "intentsId": intentsId }, |
| 2081 | returnBool=True, specificDriver=2 ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 2082 | if stateCheckResults: |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 2083 | main.log.info( itemName + ": Intents state check passed" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 2084 | else: |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 2085 | main.log.warn( "Intents state check failed" ) |
Shreya | ca8990f | 2017-03-16 11:43:11 -0700 | [diff] [blame] | 2086 | intentResult = main.FALSE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 2087 | return intentResult |
| 2088 | |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 2089 | |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 2090 | def checkBandwidthAllocations( main, bandwidth ): |
| 2091 | """ |
| 2092 | Compare the given bandwith allocation output to the cli output on each node |
| 2093 | Returns main.TRUE or main.FALSE |
| 2094 | """ |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 2095 | stateCheckResults = main.Cluster.command( "compareBandwidthAllocations", |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 2096 | args=[ bandwidth ], |
| 2097 | returnBool=True, specificDriver=2 ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 2098 | if stateCheckResults: |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 2099 | main.log.info( itemName + ": bandwidth check passed" ) |
| 2100 | bandwidthResult = main.TRUE |
| 2101 | else: |
| 2102 | main.log.warn( itemName + ": bandwidth check failed" ) |
| 2103 | bandwidthResult = main.FALSE |
| 2104 | return bandwidthResult |
| 2105 | |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 2106 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 2107 | def checkFlowsState( main ): |
| 2108 | |
| 2109 | main.log.info( itemName + ": Check flows state" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 2110 | checkFlowsResult = main.Cluster.active( 0 ).CLI.checkFlowsState( isPENDING=False ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 2111 | return checkFlowsResult |
| 2112 | |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 2113 | |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 2114 | def link( main, sw1, sw2, option ): |
You Wang | f6574de | 2018-02-09 14:43:47 -0800 | [diff] [blame] | 2115 | if main.usePortstate: |
| 2116 | # port down |
| 2117 | dpid = main.params[ 'MININET' ][ 'dpids' ][ sw1 ] |
| 2118 | port = main.params[ 'MININET' ][ 'ports' ][ sw1 ][ sw2 ] |
| 2119 | main.log.info( itemName + ": Bring port " + sw1 + "/" + port + " " + option ) |
| 2120 | state = "disable" if option == "down" else "enable" |
| 2121 | result = main.Cluster.active( 0 ).CLI.portstate( dpid=dpid, port=port, state=state ) |
| 2122 | else: |
| 2123 | # link down |
| 2124 | main.log.info( itemName + ": Bring link " + option + " between " + |
| 2125 | sw1 + " and " + sw2 ) |
| 2126 | result = main.Network.link( end1=sw1, end2=sw2, option=option ) |
| 2127 | return result |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 2128 | |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 2129 | |
Jon Hall | af95c3e | 2017-05-16 13:20:37 -0700 | [diff] [blame] | 2130 | def scapyCheckConnection( main, |
| 2131 | senders, |
| 2132 | recipients, |
| 2133 | vlanId=None, |
| 2134 | useTCP=False, |
| 2135 | packet=None, |
| 2136 | packetFilter=None, |
| 2137 | expectFailure=False ): |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 2138 | """ |
| 2139 | Checks the connectivity between all given sender hosts and all given recipient hosts |
| 2140 | Packet may be specified. Defaults to Ether/IP packet |
| 2141 | Packet Filter may be specified. Defaults to Ether/IP from current sender MAC |
| 2142 | Todo: Optional packet and packet filter attributes for sender and recipients |
| 2143 | Expect Failure when the sender and recipient are not supposed to have connectivity |
| 2144 | Timeout of 1 second, returns main.TRUE if the filter is not triggered and kills the filter |
| 2145 | |
| 2146 | """ |
| 2147 | connectionsFunctional = main.TRUE |
| 2148 | |
| 2149 | if not packetFilter: |
| 2150 | packetFilter = 'ether host {}' |
Jeremy Songster | e405d3d | 2016-05-17 11:18:57 -0700 | [diff] [blame] | 2151 | if useTCP: |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 2152 | packetFilter += ' ip proto \\tcp tcp port {}'.format( main.params[ 'SDNIP' ][ 'dstPort' ] ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 2153 | if expectFailure: |
| 2154 | timeout = 1 |
| 2155 | else: |
| 2156 | timeout = 10 |
| 2157 | |
| 2158 | for sender in senders: |
| 2159 | try: |
| 2160 | senderComp = getattr( main, sender ) |
| 2161 | except AttributeError: |
| 2162 | main.log.error( "main has no attribute {}".format( sender ) ) |
| 2163 | connectionsFunctional = main.FALSE |
| 2164 | continue |
| 2165 | |
| 2166 | for recipient in recipients: |
| 2167 | # Do not send packets to self since recipient CLI will already be busy |
| 2168 | if recipient == sender: |
| 2169 | continue |
| 2170 | try: |
| 2171 | recipientComp = getattr( main, recipient ) |
| 2172 | except AttributeError: |
| 2173 | main.log.error( "main has no attribute {}".format( recipient ) ) |
| 2174 | connectionsFunctional = main.FALSE |
| 2175 | continue |
| 2176 | |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 2177 | if vlanId: |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 2178 | recipientComp.startFilter( pktFilter=( "vlan {}".format( vlanId ) + " && " + packetFilter.format( senderComp.hostMac ) ) ) |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 2179 | else: |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 2180 | recipientComp.startFilter( pktFilter=packetFilter.format( senderComp.hostMac ) ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 2181 | |
| 2182 | if not packet: |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 2183 | if vlanId: |
| 2184 | pkt = 'Ether( src="{0}", dst="{2}" )/Dot1Q(vlan={4})/IP( src="{1}", dst="{3}" )'.format( |
| 2185 | senderComp.hostMac, |
| 2186 | senderComp.hostIp, |
| 2187 | recipientComp.hostMac, |
| 2188 | recipientComp.hostIp, |
| 2189 | vlanId ) |
| 2190 | else: |
| 2191 | pkt = 'Ether( src="{0}", dst="{2}" )/IP( src="{1}", dst="{3}" )'.format( |
| 2192 | senderComp.hostMac, |
| 2193 | senderComp.hostIp, |
| 2194 | recipientComp.hostMac, |
| 2195 | recipientComp.hostIp ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 2196 | else: |
| 2197 | pkt = packet |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 2198 | if vlanId: |
| 2199 | senderComp.sendPacket( iface=( "{0}-eth0.{1}".format( sender, vlanId ) ), packet = pkt ) |
| 2200 | else: |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 2201 | senderComp.sendPacket( packet=pkt ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 2202 | |
| 2203 | if recipientComp.checkFilter( timeout ): |
| 2204 | if expectFailure: |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 2205 | main.log.error( "Packet from {0} successfully received by {1} when it should not have been".format( sender, recipient ) ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 2206 | connectionsFunctional = main.FALSE |
| 2207 | else: |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 2208 | main.log.info( "Packet from {0} successfully received by {1}".format( sender, recipient ) ) |
alison | 52b2589 | 2016-09-19 10:53:48 -0700 | [diff] [blame] | 2209 | connectionsFunctional = main.TRUE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 2210 | else: |
| 2211 | recipientComp.killFilter() |
| 2212 | if expectFailure: |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 2213 | main.log.info( "As expected, packet from {0} was not received by {1}".format( sender, recipient ) ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 2214 | else: |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 2215 | main.log.error( "Packet from {0} was not received by {1}".format( sender, recipient ) ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 2216 | connectionsFunctional = main.FALSE |
| 2217 | |
| 2218 | return connectionsFunctional |
| 2219 | |
alison | 52b2589 | 2016-09-19 10:53:48 -0700 | [diff] [blame] | 2220 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 2221 | def removeAllIntents( main, intentsId ): |
| 2222 | """ |
| 2223 | Remove all intents in the intentsId |
| 2224 | """ |
kelvin-onlab | 5c706ff | 2015-07-20 10:56:52 -0700 | [diff] [blame] | 2225 | onosSummary = [] |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 2226 | removeIntentResult = main.TRUE |
| 2227 | # Remove intents |
| 2228 | for intent in intentsId: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 2229 | main.Cluster.active( 0 ).CLI.removeIntent( intentId=intent, purge=True ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 2230 | |
Jon Hall | f539eb9 | 2017-05-22 17:18:42 -0700 | [diff] [blame] | 2231 | main.log.info( "Sleeping {} seconds".format( main.removeIntentSleep ) ) |
acsmars | cfa5227 | 2015-08-06 15:21:45 -0700 | [diff] [blame] | 2232 | time.sleep( main.removeIntentSleep ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 2233 | |
kelvin-onlab | 5c706ff | 2015-07-20 10:56:52 -0700 | [diff] [blame] | 2234 | # If there is remianing intents then remove intents should fail |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 2235 | for ctrl in main.Cluster.active(): |
| 2236 | onosSummary.append( json.loads( ctrl.CLI.summary() ) ) |
kelvin-onlab | 5c706ff | 2015-07-20 10:56:52 -0700 | [diff] [blame] | 2237 | |
| 2238 | for summary in onosSummary: |
| 2239 | if summary.get( 'intents' ) != 0: |
| 2240 | main.log.warn( itemName + ": There are " + |
| 2241 | str( summary.get( 'intents' ) ) + |
| 2242 | " intents remaining in node " + |
| 2243 | str( summary.get( 'node' ) ) + |
| 2244 | ", failed to remove all the intents " ) |
| 2245 | removeIntentResult = main.FALSE |
| 2246 | |
| 2247 | if removeIntentResult: |
| 2248 | main.log.info( itemName + ": There are no more intents remaining, " + |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 2249 | "successfully removed all the intents." ) |
kelvin-onlab | 5c706ff | 2015-07-20 10:56:52 -0700 | [diff] [blame] | 2250 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 2251 | return removeIntentResult |
| 2252 | |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 2253 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 2254 | def checkFlowsCount( main ): |
| 2255 | """ |
| 2256 | Check flows count in each node |
| 2257 | """ |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 2258 | flowsCount = [] |
| 2259 | main.log.info( itemName + ": Checking flows count in each ONOS node" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 2260 | for ctrl in main.Cluster.active(): |
| 2261 | summaryResult = ctrl.CLI.summary() |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 2262 | if not summaryResult: |
| 2263 | main.log.error( itemName + ": There is something wrong with " + |
| 2264 | "summary command" ) |
| 2265 | return main.FALSE |
| 2266 | else: |
| 2267 | summaryJson = json.loads( summaryResult ) |
| 2268 | flowsCount.append( summaryJson.get( 'flows' ) ) |
| 2269 | |
| 2270 | if flowsCount: |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 2271 | if all( flows == flowsCount[ 0 ] for flows in flowsCount ): |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 2272 | main.log.info( itemName + ": There are " + str( flowsCount[ 0 ] ) + |
| 2273 | " flows in all ONOS node" ) |
| 2274 | else: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 2275 | for i in range( main.Cluster.numCtrls ): |
| 2276 | main.log.debug( itemName + ": " + ctrl.name + " has " + |
| 2277 | str( flowsCount[ ctrl.pos ] ) + " flows" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 2278 | else: |
| 2279 | main.log.error( "Checking flows count failed, check summary command" ) |
| 2280 | return main.FALSE |
| 2281 | |
| 2282 | return main.TRUE |
| 2283 | |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 2284 | |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 2285 | def checkLeaderChange( leaders1, leaders2 ): |
acsmars | e6b410f | 2015-07-17 14:39:34 -0700 | [diff] [blame] | 2286 | """ |
| 2287 | Checks for a change in intent partition leadership. |
| 2288 | |
| 2289 | Takes the output of leaders -c in json string format before and after |
| 2290 | a potential change as input |
| 2291 | |
| 2292 | Returns main.TRUE if no mismatches are detected |
| 2293 | Returns main.FALSE if there is a mismatch or on error loading the input |
| 2294 | """ |
| 2295 | try: |
| 2296 | leaders1 = json.loads( leaders1 ) |
| 2297 | leaders2 = json.loads( leaders2 ) |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 2298 | except( AttributeError, TypeError ): |
Jon Hall | d970abf | 2017-05-23 10:20:28 -0700 | [diff] [blame] | 2299 | main.log.exception( "checkLeaderChange: Object not as expected" ) |
acsmars | e6b410f | 2015-07-17 14:39:34 -0700 | [diff] [blame] | 2300 | return main.FALSE |
| 2301 | except Exception: |
Jon Hall | d970abf | 2017-05-23 10:20:28 -0700 | [diff] [blame] | 2302 | main.log.exception( "checkLeaderChange: Uncaught exception!" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 2303 | main.cleanAndExit() |
| 2304 | |
acsmars | e6b410f | 2015-07-17 14:39:34 -0700 | [diff] [blame] | 2305 | main.log.info( "Checking Intent Paritions for Change in Leadership" ) |
| 2306 | mismatch = False |
| 2307 | for dict1 in leaders1: |
| 2308 | if "intent" in dict1.get( "topic", [] ): |
| 2309 | for dict2 in leaders2: |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 2310 | if dict1.get( "topic", 0 ) == dict2.get( "topic", 0 ) and\ |
| 2311 | dict1.get( "leader", 0 ) != dict2.get( "leader", 0 ): |
acsmars | e6b410f | 2015-07-17 14:39:34 -0700 | [diff] [blame] | 2312 | mismatch = True |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 2313 | main.log.error( "%s changed leader from %s to %s", |
| 2314 | dict1.get( "topic", "no-topic" ), |
| 2315 | dict1.get( "leader", "no-leader" ), |
| 2316 | dict2.get( "leader", "no-leader" ) ) |
acsmars | e6b410f | 2015-07-17 14:39:34 -0700 | [diff] [blame] | 2317 | if mismatch: |
| 2318 | return main.FALSE |
| 2319 | else: |
| 2320 | return main.TRUE |
kelvin-onlab | 016dce2 | 2015-08-10 09:54:11 -0700 | [diff] [blame] | 2321 | |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 2322 | |
kelvin-onlab | 016dce2 | 2015-08-10 09:54:11 -0700 | [diff] [blame] | 2323 | def report( main ): |
| 2324 | """ |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 2325 | Report errors/warnings/exceptions |
kelvin-onlab | 016dce2 | 2015-08-10 09:54:11 -0700 | [diff] [blame] | 2326 | """ |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 2327 | main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, |
kelvin-onlab | 016dce2 | 2015-08-10 09:54:11 -0700 | [diff] [blame] | 2328 | [ "INFO", |
| 2329 | "FOLLOWER", |
| 2330 | "WARN", |
| 2331 | "flow", |
| 2332 | "ERROR", |
| 2333 | "Except" ], |
| 2334 | "s" ) |
| 2335 | |
| 2336 | main.log.info( "ERROR report: \n" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 2337 | for ctrl in main.Cluster.active(): |
| 2338 | main.ONOSbench.logReport( ctrl.ipAddress, |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 2339 | [ "ERROR" ], |
| 2340 | "d" ) |
kelvin-onlab | 016dce2 | 2015-08-10 09:54:11 -0700 | [diff] [blame] | 2341 | |
| 2342 | main.log.info( "EXCEPTIONS report: \n" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 2343 | for ctrl in main.Cluster.active(): |
| 2344 | main.ONOSbench.logReport( ctrl.ipAddress, |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 2345 | [ "Except" ], |
| 2346 | "d" ) |
kelvin-onlab | 016dce2 | 2015-08-10 09:54:11 -0700 | [diff] [blame] | 2347 | |
| 2348 | main.log.info( "WARNING report: \n" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 2349 | for ctrl in main.Cluster.active(): |
| 2350 | main.ONOSbench.logReport( ctrl.ipAddress, |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 2351 | [ "WARN" ], |
| 2352 | "d" ) |
| 2353 | |
Jeremy Songster | 306ed7a | 2016-07-19 10:59:07 -0700 | [diff] [blame] | 2354 | |
| 2355 | def flowDuration( main ): |
| 2356 | """ |
| 2357 | Check age of flows to see if flows are being overwritten |
| 2358 | """ |
Jeremy Songster | 306ed7a | 2016-07-19 10:59:07 -0700 | [diff] [blame] | 2359 | main.log.info( "Getting current flow durations" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 2360 | flowsJson1 = main.Cluster.active( 0 ).CLI.flows( noCore=True ) |
Jeremy Songster | 306ed7a | 2016-07-19 10:59:07 -0700 | [diff] [blame] | 2361 | try: |
| 2362 | flowsJson1 = json.loads( flowsJson1 ) |
| 2363 | except ValueError: |
| 2364 | main.log.error( "Unable to read flows" ) |
| 2365 | return main.FALSE |
| 2366 | flowLife = [] |
| 2367 | waitFlowLife = [] |
| 2368 | for device in flowsJson1: |
| 2369 | if device.get( 'flowcount', 0 ) > 0: |
| 2370 | for i in range( device[ 'flowCount' ] ): |
| 2371 | flowLife.append( device[ 'flows' ][ i ][ 'life' ] ) |
| 2372 | main.log.info( "Sleeping for {} seconds".format( main.flowDurationSleep ) ) |
| 2373 | time.sleep( main.flowDurationSleep ) |
| 2374 | main.log.info( "Getting new flow durations" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 2375 | flowsJson2 = main.Cluster.active( 0 ).CLI.flows( noCore=True ) |
Jeremy Songster | 306ed7a | 2016-07-19 10:59:07 -0700 | [diff] [blame] | 2376 | try: |
| 2377 | flowsJson2 = json.loads( flowsJson2 ) |
| 2378 | except ValueError: |
| 2379 | main.log.error( "Unable to read flows" ) |
| 2380 | return main.FALSE |
| 2381 | for device in flowsJson2: |
| 2382 | if device.get( 'flowcount', 0 ) > 0: |
| 2383 | for i in range( device[ 'flowCount' ] ): |
| 2384 | waitFlowLife.append( device[ 'flows' ][ i ][ 'life' ] ) |
| 2385 | main.log.info( "Determining whether flows where overwritten" ) |
| 2386 | if len( flowLife ) == len( waitFlowLife ): |
alison | 52b2589 | 2016-09-19 10:53:48 -0700 | [diff] [blame] | 2387 | for i in range( len( flowLife ) ): |
Jeremy Songster | 306ed7a | 2016-07-19 10:59:07 -0700 | [diff] [blame] | 2388 | if waitFlowLife[ i ] - flowLife[ i ] < main.flowDurationSleep: |
| 2389 | return main.FALSE |
| 2390 | else: |
| 2391 | return main.FALSE |
| 2392 | return main.TRUE |
alison | 52b2589 | 2016-09-19 10:53:48 -0700 | [diff] [blame] | 2393 | |
| 2394 | |
| 2395 | def EncapsulatedIntentCheck( main, tag="" ): |
| 2396 | """ |
| 2397 | Check encapsulated intents |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 2398 | tag: encapsulation tag ( e.g. VLAN, MPLS ) |
alison | 52b2589 | 2016-09-19 10:53:48 -0700 | [diff] [blame] | 2399 | |
| 2400 | Getting added flows |
| 2401 | Check tags on each flows |
| 2402 | If each direction has push or pop, passed |
| 2403 | else failed |
| 2404 | |
| 2405 | """ |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 2406 | main.log.info( "Checking encapsulated intent for " + tag + "." ) |
alison | 52b2589 | 2016-09-19 10:53:48 -0700 | [diff] [blame] | 2407 | HostJson = [] |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 2408 | Jflows = main.Cluster.active( 0 ).CLI.flows( noCore=True ) |
alison | 52b2589 | 2016-09-19 10:53:48 -0700 | [diff] [blame] | 2409 | try: |
| 2410 | Jflows = json.loads( Jflows ) |
| 2411 | except ValueError: |
| 2412 | main.log.error( "Unable to read flows" ) |
| 2413 | return main.FALSE |
| 2414 | |
| 2415 | for flow in Jflows: |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 2416 | if len( flow[ "flows" ] ) != 0: |
alison | 52b2589 | 2016-09-19 10:53:48 -0700 | [diff] [blame] | 2417 | HostJson.append( flow[ "flows" ] ) |
| 2418 | |
Jon Hall | 78be496 | 2017-05-23 14:53:53 -0700 | [diff] [blame] | 2419 | totalflows = len( HostJson[ 0 ] ) |
alison | 52b2589 | 2016-09-19 10:53:48 -0700 | [diff] [blame] | 2420 | |
| 2421 | pop = 0 |
| 2422 | push = 0 |
| 2423 | |
| 2424 | PopTag = tag + "_POP" |
| 2425 | PushTag = tag + "_PUSH" |
Devin Lim | f6d287d | 2017-08-04 14:39:11 -0700 | [diff] [blame] | 2426 | main.log.info( "Host Json info :" ) |
alison | 52b2589 | 2016-09-19 10:53:48 -0700 | [diff] [blame] | 2427 | for EachHostJson in HostJson: |
| 2428 | for i in range( totalflows ): |
Devin Lim | f6d287d | 2017-08-04 14:39:11 -0700 | [diff] [blame] | 2429 | main.log.info( str( EachHostJson[ i ] ) ) |
| 2430 | checkJson = EachHostJson[ i ][ "treatment" ][ "instructions" ][ 0 ] |
| 2431 | main.Cluster.active( 0 ).REST.pprint( checkJson ) |
| 2432 | if 'subtype' in checkJson: |
| 2433 | if checkJson[ "subtype" ] == PopTag: |
| 2434 | pop += 1 |
| 2435 | elif checkJson[ "subtype" ] == PushTag: |
| 2436 | push += 1 |
alison | 52b2589 | 2016-09-19 10:53:48 -0700 | [diff] [blame] | 2437 | |
| 2438 | if pop == totalflows and push == totalflows: |
| 2439 | return main.TRUE |
| 2440 | else: |
Devin Lim | f6d287d | 2017-08-04 14:39:11 -0700 | [diff] [blame] | 2441 | main.log.error( "Total " + PushTag + str( push ) ) |
| 2442 | main.log.error( "Total " + PopTag + str( pop ) ) |
alison | da15727 | 2016-12-22 01:13:21 -0800 | [diff] [blame] | 2443 | return main.FALSE |
| 2444 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 2445 | |
alison | da15727 | 2016-12-22 01:13:21 -0800 | [diff] [blame] | 2446 | def ProtectedIntentCheck( main ): |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 2447 | intent = main.Cluster.active( 0 ).CLI.intents( jsonFormat=False ) |
alison | da15727 | 2016-12-22 01:13:21 -0800 | [diff] [blame] | 2448 | if "Protection" in intent: |
| 2449 | return main.TRUE |
Shreya | ca8990f | 2017-03-16 11:43:11 -0700 | [diff] [blame] | 2450 | return main.FALSE |