Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 1 | """ |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 2 | Copyright 2016 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 | """ |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 21 | import os |
| 22 | import imp |
| 23 | import time |
| 24 | import json |
| 25 | import urllib |
| 26 | from core import utilities |
| 27 | |
| 28 | |
| 29 | class Testcaselib: |
Pier | fb719b1 | 2016-09-19 14:51:44 -0700 | [diff] [blame] | 30 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 31 | useSSH = True |
Pier | fb719b1 | 2016-09-19 14:51:44 -0700 | [diff] [blame] | 32 | |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 33 | @staticmethod |
| 34 | def initTest( main ): |
| 35 | """ |
| 36 | - Construct tests variables |
| 37 | - GIT ( optional ) |
| 38 | - Checkout ONOS master branch |
| 39 | - Pull latest ONOS code |
| 40 | - Building ONOS ( optional ) |
| 41 | - Install ONOS package |
| 42 | - Build ONOS package |
| 43 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 44 | try: |
| 45 | from tests.dependencies.ONOSSetup import ONOSSetup |
| 46 | main.testSetUp = ONOSSetup() |
| 47 | except ImportError: |
| 48 | main.log.error( "ONOSSetup not found. exiting the test" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 49 | main.cleanAndExit() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 50 | main.testSetUp.envSetupDescription() |
| 51 | stepResult = main.FALSE |
| 52 | try: |
| 53 | main.step( "Constructing test variables" ) |
| 54 | # Test variables |
| 55 | main.cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 56 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
| 57 | main.diff = main.params[ 'ENV' ][ 'diffApps' ] |
| 58 | main.path = os.path.dirname( main.testFile ) |
| 59 | main.dependencyPath = main.path + "/../dependencies/" |
| 60 | main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ] |
| 61 | wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 62 | main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 63 | main.maxNodes = int( main.params[ 'SCALE' ][ 'max' ] ) |
| 64 | # main.ONOSport = main.params[ 'CTRL' ][ 'port' ] |
| 65 | main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] ) |
| 66 | # -- INIT SECTION, ONLY RUNS ONCE -- # |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 67 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 68 | copyResult1 = main.ONOSbench.scp( main.Mininet1, |
| 69 | main.dependencyPath + |
| 70 | main.topology, |
| 71 | main.Mininet1.home, |
| 72 | direction="to" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 73 | stepResult = main.testSetUp.envSetup() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 74 | except Exception as e: |
| 75 | main.testSetUp.envSetupException( e ) |
Jonghwan Hyun | 3731d6a | 2017-10-19 11:59:31 -0700 | [diff] [blame] | 76 | |
| 77 | # Additional files for topology building |
| 78 | try: |
| 79 | main.topologyLib1 = main.params[ 'DEPENDENCY' ][ 'lib1' ] |
| 80 | main.topologyLib2 = main.params[ 'DEPENDENCY' ][ 'lib2' ] |
| 81 | copyResult2 = main.ONOSbench.scp(main.Mininet1, |
| 82 | main.dependencyPath + |
| 83 | main.topologyLib1, |
| 84 | main.Mininet1.home, |
| 85 | direction="to") |
| 86 | copyResult3 = main.ONOSbench.scp(main.Mininet1, |
| 87 | main.dependencyPath + |
| 88 | main.topologyLib2, |
| 89 | main.Mininet1.home, |
| 90 | direction="to") |
| 91 | except: |
| 92 | pass |
| 93 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 94 | main.testSetUp.evnSetupConclusion( stepResult ) |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 95 | |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 96 | @staticmethod |
You Wang | 1cdc5f5 | 2017-12-19 16:47:51 -0800 | [diff] [blame] | 97 | def installOnos( main, vlanCfg=True, skipPackage=False, cliSleep=10 ): |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 98 | """ |
| 99 | - Set up cell |
| 100 | - Create cell file |
| 101 | - Set cell file |
| 102 | - Verify cell file |
| 103 | - Kill ONOS process |
| 104 | - Uninstall ONOS cluster |
| 105 | - Verify ONOS start up |
| 106 | - Install ONOS cluster |
| 107 | - Connect to cli |
| 108 | """ |
| 109 | # main.scale[ 0 ] determines the current number of ONOS controller |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 110 | if main.diff: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 111 | main.apps = main.apps + "," + main.diff |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 112 | else: |
| 113 | main.log.error( "App list is empty" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 114 | main.log.info( "NODE COUNT = " + str( main.Cluster.numCtrls ) ) |
| 115 | main.log.info( ''.join( main.Cluster.getIps() ) ) |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 116 | main.dynamicHosts = [ 'in1', 'out1' ] |
You Wang | 1cdc5f5 | 2017-12-19 16:47:51 -0800 | [diff] [blame] | 117 | main.testSetUp.ONOSSetUp( main.Mininet1, main.Cluster, newCell=True, cellName=main.cellName, |
| 118 | skipPack=skipPackage, useSSH=Testcaselib.useSSH ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 119 | ready = utilities.retry( main.Cluster.active( 0 ).CLI.summary, |
| 120 | main.FALSE, |
You Wang | 1cdc5f5 | 2017-12-19 16:47:51 -0800 | [diff] [blame] | 121 | sleep=cliSleep, |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 122 | attempts=10 ) |
| 123 | if ready: |
| 124 | ready = main.TRUE |
| 125 | utilities.assert_equals( expect=main.TRUE, actual=ready, |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 126 | onpass="ONOS summary command succeded", |
| 127 | onfail="ONOS summary command failed" ) |
| 128 | |
| 129 | with open( "%s/json/%s.json" % ( |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 130 | main.dependencyPath, main.cfgName ) ) as cfg: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 131 | main.Cluster.active( 0 ).REST.setNetCfg( json.load( cfg ) ) |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 132 | with open( "%s/json/%s.chart" % ( |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 133 | main.dependencyPath, main.cfgName ) ) as chart: |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 134 | main.pingChart = json.load( chart ) |
| 135 | if not ready: |
| 136 | main.log.error( "ONOS startup failed!" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 137 | main.cleanAndExit() |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 138 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 139 | for ctrl in main.Cluster.active(): |
| 140 | ctrl.CLI.logSet( "DEBUG", "org.onosproject.segmentrouting" ) |
| 141 | ctrl.CLI.logSet( "DEBUG", "org.onosproject.driver.pipeline" ) |
| 142 | ctrl.CLI.logSet( "DEBUG", "org.onosproject.store.group.impl" ) |
| 143 | ctrl.CLI.logSet( "DEBUG", "org.onosproject.net.flowobjective.impl" ) |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 144 | |
| 145 | @staticmethod |
| 146 | def startMininet( main, topology, args="" ): |
| 147 | main.step( "Starting Mininet Topology" ) |
Jonghwan Hyun | 3731d6a | 2017-10-19 11:59:31 -0700 | [diff] [blame] | 148 | arg = "--onos-ip=%s %s" % (",".join([ctrl.ipAddress for ctrl in main.Cluster.runningNodes]), args) |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 149 | main.topology = topology |
| 150 | topoResult = main.Mininet1.startNet( |
| 151 | topoFile=main.Mininet1.home + main.topology, args=arg ) |
| 152 | stepResult = topoResult |
| 153 | utilities.assert_equals( expect=main.TRUE, |
| 154 | actual=stepResult, |
| 155 | onpass="Successfully loaded topology", |
| 156 | onfail="Failed to load topology" ) |
| 157 | # Exit if topology did not load properly |
| 158 | if not topoResult: |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 159 | main.cleanAndExit() |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 160 | |
| 161 | @staticmethod |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 162 | def config( main, cfgName ): |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 163 | main.spines = [] |
Pier | a2a7e1b | 2016-10-04 11:51:43 -0700 | [diff] [blame] | 164 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 165 | main.failures = int( main.params[ 'failures' ] ) |
| 166 | main.cfgName = cfgName |
Pier | a2a7e1b | 2016-10-04 11:51:43 -0700 | [diff] [blame] | 167 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 168 | if main.cfgName == '2x2': |
| 169 | spine = {} |
| 170 | spine[ 'name' ] = main.params[ 'switches' ][ 'spine1' ] |
| 171 | spine[ 'dpid' ] = main.params[ 'switches' ][ 'spinedpid1' ] |
| 172 | main.spines.append( spine ) |
Pier | a2a7e1b | 2016-10-04 11:51:43 -0700 | [diff] [blame] | 173 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 174 | spine = {} |
| 175 | spine[ 'name' ] = main.params[ 'switches' ][ 'spine2' ] |
| 176 | spine[ 'dpid' ] = main.params[ 'switches' ][ 'spinedpid2' ] |
| 177 | main.spines.append( spine ) |
Pier | a2a7e1b | 2016-10-04 11:51:43 -0700 | [diff] [blame] | 178 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 179 | elif main.cfgName == '4x4': |
| 180 | spine = {} |
| 181 | spine[ 'name' ] = main.params[ 'switches' ][ 'spine1' ] |
| 182 | spine[ 'dpid' ] = main.params[ 'switches' ][ 'spinedpid1' ] |
| 183 | main.spines.append( spine ) |
Pier | a2a7e1b | 2016-10-04 11:51:43 -0700 | [diff] [blame] | 184 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 185 | spine = {} |
| 186 | spine[ 'name' ] = main.params[ 'switches' ][ 'spine2' ] |
| 187 | spine[ 'dpid' ] = main.params[ 'switches' ][ 'spinedpid2' ] |
| 188 | main.spines.append( spine ) |
Pier | a2a7e1b | 2016-10-04 11:51:43 -0700 | [diff] [blame] | 189 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 190 | spine = {} |
| 191 | spine[ 'name' ] = main.params[ 'switches' ][ 'spine3' ] |
| 192 | spine[ 'dpid' ] = main.params[ 'switches' ][ 'spinedpid3' ] |
| 193 | main.spines.append( spine ) |
Pier | a2a7e1b | 2016-10-04 11:51:43 -0700 | [diff] [blame] | 194 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 195 | spine = {} |
| 196 | spine[ 'name' ] = main.params[ 'switches' ][ 'spine4' ] |
| 197 | spine[ 'dpid' ] = main.params[ 'switches' ][ 'spinedpid4' ] |
| 198 | main.spines.append( spine ) |
Pier | a2a7e1b | 2016-10-04 11:51:43 -0700 | [diff] [blame] | 199 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 200 | else: |
Pier | a2a7e1b | 2016-10-04 11:51:43 -0700 | [diff] [blame] | 201 | main.log.error( "Configuration failed!" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 202 | main.cleanAndExit() |
Pier | a2a7e1b | 2016-10-04 11:51:43 -0700 | [diff] [blame] | 203 | |
| 204 | @staticmethod |
You Wang | 1cdc5f5 | 2017-12-19 16:47:51 -0800 | [diff] [blame] | 205 | def checkFlows( main, minFlowCount, dumpflows=True, sleep=10 ): |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 206 | main.step( |
| 207 | " Check whether the flow count is bigger than %s" % minFlowCount ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 208 | count = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowCount, |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 209 | main.FALSE, |
| 210 | kwargs={ 'min': minFlowCount }, |
| 211 | attempts=10, |
You Wang | 1cdc5f5 | 2017-12-19 16:47:51 -0800 | [diff] [blame] | 212 | sleep=sleep ) |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 213 | utilities.assertEquals( |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 214 | expect=True, |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 215 | actual=( count > 0 ), |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 216 | onpass="Flow count looks correct: " + str( count ), |
| 217 | onfail="Flow count looks wrong: " + str( count ) ) |
| 218 | |
| 219 | main.step( "Check whether all flow status are ADDED" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 220 | flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState, |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 221 | main.FALSE, |
| 222 | kwargs={ 'isPENDING': False }, |
Jonghwan Hyun | 98fb40a | 2018-01-04 16:16:28 -0800 | [diff] [blame] | 223 | attempts=5, |
You Wang | 1cdc5f5 | 2017-12-19 16:47:51 -0800 | [diff] [blame] | 224 | sleep=sleep ) |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 225 | utilities.assertEquals( |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 226 | expect=main.TRUE, |
| 227 | actual=flowCheck, |
| 228 | onpass="Flow status is correct!", |
| 229 | onfail="Flow status is wrong!" ) |
| 230 | if dumpflows: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 231 | main.ONOSbench.dumpONOSCmd( main.Cluster.active( 0 ).ipAddress, |
Pier | 50f0bc6 | 2016-09-07 17:53:40 -0700 | [diff] [blame] | 232 | "flows", |
| 233 | main.logdir, |
| 234 | "flowsBefore" + main.cfgName ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 235 | main.ONOSbench.dumpONOSCmd( main.Cluster.active( 0 ).ipAddress, |
Pier | 50f0bc6 | 2016-09-07 17:53:40 -0700 | [diff] [blame] | 236 | "groups", |
| 237 | main.logdir, |
| 238 | "groupsBefore" + main.cfgName ) |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 239 | |
| 240 | @staticmethod |
Jonghwan Hyun | 98fb40a | 2018-01-04 16:16:28 -0800 | [diff] [blame] | 241 | def checkFlowsByDpid( main, dpid, minFlowCount, sleep=10 ): |
| 242 | main.step( |
| 243 | " Check whether the flow count of device %s is bigger than %s" % ( dpid, minFlowCount ) ) |
| 244 | count = utilities.retry( main.Cluster.active( 0 ).CLI.flowAddedCount, |
| 245 | None, |
| 246 | args=( dpid, ), |
| 247 | attempts=5, |
| 248 | sleep=sleep ) |
| 249 | utilities.assertEquals( |
| 250 | expect=True, |
| 251 | actual=( int( count ) > minFlowCount ), |
| 252 | onpass="Flow count looks correct: " + count , |
| 253 | onfail="Flow count looks wrong: " + count ) |
| 254 | |
| 255 | @staticmethod |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 256 | def pingAll( main, tag="", dumpflows=True ): |
| 257 | main.log.report( "Check full connectivity" ) |
| 258 | print main.pingChart |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 259 | for entry in main.pingChart.itervalues(): |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 260 | print entry |
| 261 | hosts, expect = entry[ 'hosts' ], entry[ 'expect' ] |
Jonghwan Hyun | 3731d6a | 2017-10-19 11:59:31 -0700 | [diff] [blame] | 262 | try: |
| 263 | expect = main.TRUE if str(expect).lower() == 'true' else main.FALSE |
| 264 | except: |
| 265 | expect = main.FALSE |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 266 | main.step( "Connectivity for %s %s" % ( str( hosts ), tag ) ) |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 267 | pa = main.Mininet1.pingallHosts( hosts ) |
Jonghwan Hyun | 3731d6a | 2017-10-19 11:59:31 -0700 | [diff] [blame] | 268 | |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 269 | utilities.assert_equals( expect=expect, actual=pa, |
| 270 | onpass="IP connectivity successfully tested", |
| 271 | onfail="IP connectivity failed" ) |
| 272 | if dumpflows: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 273 | main.ONOSbench.dumpONOSCmd( main.Cluster.active( 0 ).ipAddress, |
Pier | 50f0bc6 | 2016-09-07 17:53:40 -0700 | [diff] [blame] | 274 | "flows", |
| 275 | main.logdir, |
| 276 | "flowsOn" + tag ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 277 | main.ONOSbench.dumpONOSCmd( main.Cluster.active( 0 ).ipAddress, |
Pier | 50f0bc6 | 2016-09-07 17:53:40 -0700 | [diff] [blame] | 278 | "groups", |
| 279 | main.logdir, |
| 280 | "groupsOn" + tag ) |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 281 | |
| 282 | @staticmethod |
| 283 | def killLink( main, end1, end2, switches, links ): |
| 284 | """ |
| 285 | end1,end2: identify the switches, ex.: 'leaf1', 'spine1' |
| 286 | switches, links: number of expected switches and links after linkDown, ex.: '4', '6' |
| 287 | Kill a link and verify ONOS can see the proper link change |
| 288 | """ |
| 289 | main.linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 290 | main.step( "Kill link between %s and %s" % ( end1, end2 ) ) |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 291 | LinkDown = main.Mininet1.link( END1=end1, END2=end2, OPTION="down" ) |
Pier | fb719b1 | 2016-09-19 14:51:44 -0700 | [diff] [blame] | 292 | LinkDown = main.Mininet1.link( END2=end1, END1=end2, OPTION="down" ) |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 293 | main.log.info( |
| 294 | "Waiting %s seconds for link down to be discovered" % main.linkSleep ) |
| 295 | time.sleep( main.linkSleep ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 296 | topology = utilities.retry( main.Cluster.active( 0 ).CLI.checkStatus, |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 297 | main.FALSE, |
| 298 | kwargs={ 'numoswitch': switches, |
| 299 | 'numolink': links }, |
| 300 | attempts=10, |
| 301 | sleep=main.linkSleep ) |
| 302 | result = topology & LinkDown |
| 303 | utilities.assert_equals( expect=main.TRUE, actual=result, |
| 304 | onpass="Link down successful", |
| 305 | onfail="Failed to turn off link?" ) |
| 306 | |
| 307 | @staticmethod |
| 308 | def restoreLink( main, end1, end2, dpid1, dpid2, port1, port2, switches, |
| 309 | links ): |
| 310 | """ |
| 311 | Params: |
| 312 | end1,end2: identify the end switches, ex.: 'leaf1', 'spine1' |
| 313 | dpid1, dpid2: dpid of the end switches respectively, ex.: 'of:0000000000000002' |
| 314 | port1, port2: respective port of the end switches that connects to the link, ex.:'1' |
| 315 | switches, links: number of expected switches and links after linkDown, ex.: '4', '6' |
| 316 | Kill a link and verify ONOS can see the proper link change |
| 317 | """ |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 318 | main.step( "Restore link between %s and %s" % ( end1, end2 ) ) |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 319 | result = False |
| 320 | count = 0 |
| 321 | while True: |
| 322 | count += 1 |
| 323 | main.Mininet1.link( END1=end1, END2=end2, OPTION="up" ) |
| 324 | main.Mininet1.link( END2=end1, END1=end2, OPTION="up" ) |
| 325 | main.log.info( |
| 326 | "Waiting %s seconds for link up to be discovered" % main.linkSleep ) |
| 327 | time.sleep( main.linkSleep ) |
Pier | fb719b1 | 2016-09-19 14:51:44 -0700 | [diff] [blame] | 328 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 329 | for i in range( 0, main.Cluster.numCtrls ): |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 330 | ctrl = main.Cluster.runningNodes[ i ] |
| 331 | onosIsUp = main.ONOSbench.isup( ctrl.ipAddress ) |
Pier | fb719b1 | 2016-09-19 14:51:44 -0700 | [diff] [blame] | 332 | if onosIsUp == main.TRUE: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 333 | ctrl.CLI.portstate( dpid=dpid1, port=port1 ) |
| 334 | ctrl.CLI.portstate( dpid=dpid2, port=port2 ) |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 335 | time.sleep( main.linkSleep ) |
| 336 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 337 | result = main.Cluster.active( 0 ).CLI.checkStatus( numoswitch=switches, |
| 338 | numolink=links ) |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 339 | if count > 5 or result: |
| 340 | break |
| 341 | utilities.assert_equals( expect=main.TRUE, actual=result, |
| 342 | onpass="Link up successful", |
| 343 | onfail="Failed to bring link up" ) |
| 344 | |
| 345 | @staticmethod |
| 346 | def killSwitch( main, switch, switches, links ): |
| 347 | """ |
| 348 | Params: switches, links: number of expected switches and links after SwitchDown, ex.: '4', '6' |
| 349 | Completely kill a switch and verify ONOS can see the proper change |
| 350 | """ |
| 351 | main.switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] ) |
| 352 | main.step( "Kill " + switch ) |
| 353 | main.log.info( "Stopping" + switch ) |
| 354 | main.Mininet1.switch( SW=switch, OPTION="stop" ) |
| 355 | # todo make this repeatable |
| 356 | main.log.info( "Waiting %s seconds for switch down to be discovered" % ( |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 357 | main.switchSleep ) ) |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 358 | time.sleep( main.switchSleep ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 359 | topology = utilities.retry( main.Cluster.active( 0 ).CLI.checkStatus, |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 360 | main.FALSE, |
| 361 | kwargs={ 'numoswitch': switches, |
| 362 | 'numolink': links }, |
| 363 | attempts=10, |
| 364 | sleep=main.switchSleep ) |
| 365 | utilities.assert_equals( expect=main.TRUE, actual=topology, |
| 366 | onpass="Kill switch successful", |
| 367 | onfail="Failed to kill switch?" ) |
| 368 | |
| 369 | @staticmethod |
| 370 | def recoverSwitch( main, switch, switches, links ): |
| 371 | """ |
| 372 | Params: switches, links: number of expected switches and links after SwitchUp, ex.: '4', '6' |
| 373 | Recover a switch and verify ONOS can see the proper change |
| 374 | """ |
| 375 | # todo make this repeatable |
| 376 | main.step( "Recovering " + switch ) |
| 377 | main.log.info( "Starting" + switch ) |
| 378 | main.Mininet1.switch( SW=switch, OPTION="start" ) |
| 379 | main.log.info( "Waiting %s seconds for switch up to be discovered" % ( |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 380 | main.switchSleep ) ) |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 381 | time.sleep( main.switchSleep ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 382 | topology = utilities.retry( main.Cluster.active( 0 ).CLI.checkStatus, |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 383 | main.FALSE, |
| 384 | kwargs={ 'numoswitch': switches, |
| 385 | 'numolink': links }, |
| 386 | attempts=10, |
| 387 | sleep=main.switchSleep ) |
| 388 | utilities.assert_equals( expect=main.TRUE, actual=topology, |
| 389 | onpass="Switch recovery successful", |
| 390 | onfail="Failed to recover switch?" ) |
| 391 | |
| 392 | @staticmethod |
| 393 | def cleanup( main ): |
| 394 | """ |
| 395 | Stop Onos-cluster. |
| 396 | Stops Mininet |
| 397 | Copies ONOS log |
| 398 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 399 | try: |
| 400 | from tests.dependencies.utils import Utils |
| 401 | except ImportError: |
| 402 | main.log.error( "Utils not found exiting the test" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 403 | main.cleanAndExit() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 404 | try: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 405 | main.utils |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 406 | except ( NameError, AttributeError ): |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 407 | main.utils = Utils() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 408 | |
| 409 | main.utils.mininetCleanup( main.Mininet1 ) |
| 410 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 411 | main.utils.copyKarafLog( main.cfgName ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 412 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 413 | for ctrl in main.Cluster.active(): |
| 414 | main.ONOSbench.onosStop( ctrl.ipAddress ) |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 415 | |
| 416 | @staticmethod |
| 417 | def killOnos( main, nodes, switches, links, expNodes ): |
| 418 | """ |
| 419 | Params: nodes, integer array with position of the ONOS nodes in the CLIs array |
| 420 | switches, links, nodes: number of expected switches, links and nodes after KillOnos, ex.: '4', '6' |
| 421 | Completely Kill an ONOS instance and verify the ONOS cluster can see the proper change |
| 422 | """ |
| 423 | main.step( "Killing ONOS instance" ) |
Pier | 3b58c65 | 2016-09-26 12:03:31 -0700 | [diff] [blame] | 424 | |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 425 | for i in nodes: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 426 | killResult = main.ONOSbench.onosDie( main.Cluster.runningNodes[ i ].ipAddress ) |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 427 | utilities.assert_equals( expect=main.TRUE, actual=killResult, |
| 428 | onpass="ONOS instance Killed", |
| 429 | onfail="Error killing ONOS instance" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 430 | main.Cluster.runningNodes[ i ].active = False |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 431 | time.sleep( 12 ) |
Pier | 3b58c65 | 2016-09-26 12:03:31 -0700 | [diff] [blame] | 432 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 433 | if len( nodes ) < main.Cluster.numCtrls: |
Pier | 3b58c65 | 2016-09-26 12:03:31 -0700 | [diff] [blame] | 434 | |
Jonghwan Hyun | 3731d6a | 2017-10-19 11:59:31 -0700 | [diff] [blame] | 435 | nodeResults = utilities.retry( main.Cluster.nodesCheck, |
Pier | 3b58c65 | 2016-09-26 12:03:31 -0700 | [diff] [blame] | 436 | False, |
Pier | 3b58c65 | 2016-09-26 12:03:31 -0700 | [diff] [blame] | 437 | attempts=5, |
| 438 | sleep=10 ) |
| 439 | utilities.assert_equals( expect=True, actual=nodeResults, |
| 440 | onpass="Nodes check successful", |
| 441 | onfail="Nodes check NOT successful" ) |
| 442 | |
| 443 | if not nodeResults: |
| 444 | for i in nodes: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 445 | ctrl = main.Cluster.runningNodes[ i ] |
Pier | 3b58c65 | 2016-09-26 12:03:31 -0700 | [diff] [blame] | 446 | main.log.debug( "{} components not ACTIVE: \n{}".format( |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 447 | ctrl.name, |
| 448 | ctrl.CLI.sendline( "scr:list | grep -v ACTIVE" ) ) ) |
Pier | 3b58c65 | 2016-09-26 12:03:31 -0700 | [diff] [blame] | 449 | main.log.error( "Failed to kill ONOS, stopping test" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 450 | main.cleanAndExit() |
Pier | 3b58c65 | 2016-09-26 12:03:31 -0700 | [diff] [blame] | 451 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 452 | topology = utilities.retry( main.Cluster.active( 0 ).checkStatus, |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 453 | main.FALSE, |
| 454 | kwargs={ 'numoswitch': switches, |
| 455 | 'numolink': links, |
| 456 | 'numoctrl': expNodes }, |
| 457 | attempts=10, |
| 458 | sleep=12 ) |
| 459 | utilities.assert_equals( expect=main.TRUE, actual=topology, |
| 460 | onpass="ONOS Instance down successful", |
| 461 | onfail="Failed to turn off ONOS Instance" ) |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 462 | |
| 463 | @staticmethod |
| 464 | def recoverOnos( main, nodes, switches, links, expNodes ): |
| 465 | """ |
| 466 | Params: nodes, integer array with position of the ONOS nodes in the CLIs array |
| 467 | switches, links, nodes: number of expected switches, links and nodes after recoverOnos, ex.: '4', '6' |
| 468 | Recover an ONOS instance and verify the ONOS cluster can see the proper change |
| 469 | """ |
| 470 | main.step( "Recovering ONOS instance" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 471 | [ main.ONOSbench.onosStart( main.Cluster.runningNodes[ i ].ipAddress ) for i in nodes ] |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 472 | for i in nodes: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 473 | isUp = main.ONOSbench.isup( main.Cluster.runningNodes[ i ].ipAddress ) |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 474 | utilities.assert_equals( expect=main.TRUE, actual=isUp, |
| 475 | onpass="ONOS service is ready", |
| 476 | onfail="ONOS service did not start properly" ) |
| 477 | for i in nodes: |
| 478 | main.step( "Checking if ONOS CLI is ready" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 479 | ctrl = main.Cluster.runningNodes[ i ] |
| 480 | ctrl.CLI.startCellCli() |
| 481 | cliResult = ctrl.CLI.startOnosCli( ctrl.ipAddress, |
| 482 | commandlineTimeout=60, |
| 483 | onosStartTimeout=100 ) |
| 484 | ctrl.active = True |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 485 | utilities.assert_equals( expect=main.TRUE, |
| 486 | actual=cliResult, |
| 487 | onpass="ONOS CLI is ready", |
| 488 | onfail="ONOS CLI is not ready" ) |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 489 | |
Pier | 3b58c65 | 2016-09-26 12:03:31 -0700 | [diff] [blame] | 490 | main.step( "Checking ONOS nodes" ) |
Jonghwan Hyun | 3731d6a | 2017-10-19 11:59:31 -0700 | [diff] [blame] | 491 | nodeResults = utilities.retry( main.Cluster.nodesCheck, |
Pier | 3b58c65 | 2016-09-26 12:03:31 -0700 | [diff] [blame] | 492 | False, |
Pier | 3b58c65 | 2016-09-26 12:03:31 -0700 | [diff] [blame] | 493 | attempts=5, |
| 494 | sleep=10 ) |
| 495 | utilities.assert_equals( expect=True, actual=nodeResults, |
| 496 | onpass="Nodes check successful", |
| 497 | onfail="Nodes check NOT successful" ) |
| 498 | |
| 499 | if not nodeResults: |
| 500 | for i in nodes: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 501 | ctrl = main.Cluster.runningNodes[ i ] |
Pier | 3b58c65 | 2016-09-26 12:03:31 -0700 | [diff] [blame] | 502 | main.log.debug( "{} components not ACTIVE: \n{}".format( |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 503 | ctrl.name, |
| 504 | ctrl.CLI.sendline( "scr:list | grep -v ACTIVE" ) ) ) |
Pier | 3b58c65 | 2016-09-26 12:03:31 -0700 | [diff] [blame] | 505 | main.log.error( "Failed to start ONOS, stopping test" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 506 | main.cleanAndExit() |
Pier | 3b58c65 | 2016-09-26 12:03:31 -0700 | [diff] [blame] | 507 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 508 | topology = utilities.retry( main.Cluster.active( 0 ).CLI.checkStatus, |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 509 | main.FALSE, |
| 510 | kwargs={ 'numoswitch': switches, |
| 511 | 'numolink': links, |
| 512 | 'numoctrl': expNodes }, |
| 513 | attempts=10, |
| 514 | sleep=12 ) |
| 515 | utilities.assert_equals( expect=main.TRUE, actual=topology, |
| 516 | onpass="ONOS Instance down successful", |
| 517 | onfail="Failed to turn off ONOS Instance" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 518 | ready = utilities.retry( main.Cluster.active( 0 ).CLI.summary, |
| 519 | main.FALSE, |
| 520 | attempts=10, |
| 521 | sleep=12 ) |
| 522 | if ready: |
| 523 | ready = main.TRUE |
| 524 | utilities.assert_equals( expect=main.TRUE, actual=ready, |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 525 | onpass="ONOS summary command succeded", |
| 526 | onfail="ONOS summary command failed" ) |
| 527 | if not ready: |
| 528 | main.log.error( "ONOS startup failed!" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 529 | main.cleanAndExit() |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 530 | |
| 531 | @staticmethod |
| 532 | def addHostCfg( main ): |
| 533 | """ |
| 534 | Adds Host Configuration to ONOS |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 535 | Updates expected state of the network ( pingChart ) |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 536 | """ |
| 537 | import json |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 538 | hostCfg = {} |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 539 | with open( main.dependencyPath + "/json/extra.json" ) as template: |
| 540 | hostCfg = json.load( template ) |
| 541 | main.pingChart[ 'ip' ][ 'hosts' ] += [ 'in1' ] |
| 542 | main.step( "Pushing new configuration" ) |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 543 | mac, cfg = hostCfg[ 'hosts' ].popitem() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 544 | main.Cluster.active( 0 ).REST.setNetCfg( cfg[ 'basic' ], |
| 545 | subjectClass="hosts", |
| 546 | subjectKey=urllib.quote( mac, |
| 547 | safe='' ), |
| 548 | configKey="basic" ) |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 549 | main.pingChart[ 'ip' ][ 'hosts' ] += [ 'out1' ] |
| 550 | main.step( "Pushing new configuration" ) |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 551 | mac, cfg = hostCfg[ 'hosts' ].popitem() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 552 | main.Cluster.active( 0 ).REST.setNetCfg( cfg[ 'basic' ], |
| 553 | subjectClass="hosts", |
| 554 | subjectKey=urllib.quote( mac, |
| 555 | safe='' ), |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 556 | configKey="basic" ) |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 557 | main.pingChart.update( { 'vlan1': { "expect": "True", |
| 558 | "hosts": [ "olt1", "vsg1" ] } } ) |
| 559 | main.pingChart[ 'vlan5' ][ 'expect' ] = 0 |
| 560 | main.pingChart[ 'vlan10' ][ 'expect' ] = 0 |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 561 | ports = "[%s,%s]" % ( 5, 6 ) |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 562 | cfg = '{"of:0000000000000001":[{"vlan":1,"ports":%s,"name":"OLT 1"}]}' % ports |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 563 | main.Cluster.active( 0 ).REST.setNetCfg( json.loads( cfg ), |
| 564 | subjectClass="apps", |
| 565 | subjectKey="org.onosproject.segmentrouting", |
| 566 | configKey="xconnect" ) |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 567 | |
| 568 | @staticmethod |
| 569 | def delHostCfg( main ): |
| 570 | """ |
| 571 | Removest Host Configuration from ONOS |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 572 | Updates expected state of the network ( pingChart ) |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 573 | """ |
| 574 | import json |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 575 | hostCfg = {} |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 576 | with open( main.dependencyPath + "/json/extra.json" ) as template: |
| 577 | hostCfg = json.load( template ) |
| 578 | main.step( "Removing host configuration" ) |
| 579 | main.pingChart[ 'ip' ][ 'expect' ] = 0 |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 580 | mac, cfg = hostCfg[ 'hosts' ].popitem() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 581 | main.Cluster.active( 0 ).REST.removeNetCfg( subjectClass="hosts", |
| 582 | subjectKey=urllib.quote( |
| 583 | mac, |
| 584 | safe='' ), |
| 585 | configKey="basic" ) |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 586 | main.step( "Removing configuration" ) |
| 587 | main.pingChart[ 'ip' ][ 'expect' ] = 0 |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 588 | mac, cfg = hostCfg[ 'hosts' ].popitem() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 589 | main.Cluster.active( 0 ).REST.removeNetCfg( subjectClass="hosts", |
| 590 | subjectKey=urllib.quote( |
| 591 | mac, |
| 592 | safe='' ), |
| 593 | configKey="basic" ) |
Jon Hall | 1efcb3f | 2016-08-23 13:42:15 -0700 | [diff] [blame] | 594 | main.step( "Removing vlan configuration" ) |
| 595 | main.pingChart[ 'vlan1' ][ 'expect' ] = 0 |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 596 | main.Cluster.active( 0 ).REST.removeNetCfg( subjectClass="apps", |
| 597 | subjectKey="org.onosproject.segmentrouting", |
| 598 | configKey="xconnect" ) |