Cameron Franke | 2ea90e5 | 2015-01-21 10:04:16 -0800 | [diff] [blame] | 1 | # ScaleOutTemplate |
| 2 | # |
| 3 | # CASE1 starts number of nodes specified in param file |
| 4 | # |
| 5 | # cameron@onlab.us |
| 6 | |
andrew@onlab.us | c400b11 | 2015-01-21 15:33:19 -0800 | [diff] [blame] | 7 | import sys |
| 8 | import os |
Cameron Franke | 2ea90e5 | 2015-01-21 10:04:16 -0800 | [diff] [blame] | 9 | |
| 10 | |
| 11 | class ScaleOutTemplate: |
andrew@onlab.us | c400b11 | 2015-01-21 15:33:19 -0800 | [diff] [blame] | 12 | |
| 13 | def __init__( self ): |
Cameron Franke | 2ea90e5 | 2015-01-21 10:04:16 -0800 | [diff] [blame] | 14 | self.default = '' |
Cameron Franke | 2ea90e5 | 2015-01-21 10:04:16 -0800 | [diff] [blame] | 15 | |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 16 | def CASE1( self, main ): #This is the initialization case |
| 17 | #this case will clean up all nodes |
| 18 | #but only node 1 is started in this case |
| 19 | |
| 20 | global clusterCount #number of nodes running |
| 21 | global ONOSIp #list of ONOS IP addresses |
andrew@onlab.us | c400b11 | 2015-01-21 15:33:19 -0800 | [diff] [blame] | 22 | clusterCount = 1 |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 23 | ONOSIp = [ 0 ] |
andrew@onlab.us | c400b11 | 2015-01-21 15:33:19 -0800 | [diff] [blame] | 24 | |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 25 | #Load values from params file |
andrew@onlab.us | c400b11 | 2015-01-21 15:33:19 -0800 | [diff] [blame] | 26 | checkoutBranch = main.params[ 'GIT' ][ 'checkout' ] |
| 27 | gitPull = main.params[ 'GIT' ][ 'autopull' ] |
| 28 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 29 | Features= main.params[ 'ENV' ][ 'cellFeatures' ] |
andrew@onlab.us | c400b11 | 2015-01-21 15:33:19 -0800 | [diff] [blame] | 30 | BENCHIp = main.params[ 'BENCH' ][ 'ip1' ] |
| 31 | BENCHUser = main.params[ 'BENCH' ][ 'user' ] |
andrew@onlab.us | c400b11 | 2015-01-21 15:33:19 -0800 | [diff] [blame] | 32 | MN1Ip = main.params[ 'MN' ][ 'ip1' ] |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 33 | maxNodes = int(main.params[ 'availableNodes' ]) |
| 34 | Features = main.params[ 'ENV' ][ 'cellFeatures' ] |
| 35 | skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ] |
andrew@onlab.us | c400b11 | 2015-01-21 15:33:19 -0800 | [diff] [blame] | 36 | |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 37 | #Populate ONOSIp with ips from params |
| 38 | for i in range(1, maxNodes + 1): |
| 39 | ipString = 'ip' + str(i) |
| 40 | ONOSIp.append(main.params[ 'CTRL' ][ ipString ]) |
| 41 | |
| 42 | #construct the cell file |
| 43 | main.log.info("Creating cell file") |
| 44 | exec "a = main.ONOSbench.createCellFile" |
| 45 | cellIp = [] |
| 46 | for node in range (1, maxNodes + 1): |
| 47 | cellIp.append(ONOSIp[node]) |
| 48 | a(BENCHIp,cellName,MN1Ip,str(Features), *cellIp) |
| 49 | |
| 50 | #Uninstall everywhere |
andrew@onlab.us | c400b11 | 2015-01-21 15:33:19 -0800 | [diff] [blame] | 51 | main.log.step( "Cleaning Enviornment..." ) |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 52 | for i in range(1, maxNodes + 1): |
| 53 | main.log.info(" Uninstalling ONOS " + str(i) ) |
| 54 | main.ONOSbench.onosUninstall( ONOSIp[i] ) |
andrew@onlab.us | c400b11 | 2015-01-21 15:33:19 -0800 | [diff] [blame] | 55 | |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 56 | #git |
andrew@onlab.us | c400b11 | 2015-01-21 15:33:19 -0800 | [diff] [blame] | 57 | main.step( "Git checkout and pull " + checkoutBranch ) |
| 58 | if gitPull == 'on': |
| 59 | checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch ) |
| 60 | pullResult = main.ONOSbench.gitPull() |
| 61 | |
Cameron Franke | 2ea90e5 | 2015-01-21 10:04:16 -0800 | [diff] [blame] | 62 | else: |
andrew@onlab.us | c400b11 | 2015-01-21 15:33:19 -0800 | [diff] [blame] | 63 | checkoutResult = main.TRUE |
| 64 | pullResult = main.TRUE |
| 65 | main.log.info( "Skipped git checkout and pull" ) |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 66 | |
| 67 | #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test |
| 68 | if skipMvn != "yes": |
| 69 | mvnResult = main.ONOSbench.cleanInstall() |
Cameron Franke | 2ea90e5 | 2015-01-21 10:04:16 -0800 | [diff] [blame] | 70 | |
andrew@onlab.us | c400b11 | 2015-01-21 15:33:19 -0800 | [diff] [blame] | 71 | main.step( "Set cell for ONOS cli env" ) |
| 72 | main.ONOS1cli.setCell( cellName ) |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 73 | |
andrew@onlab.us | c400b11 | 2015-01-21 15:33:19 -0800 | [diff] [blame] | 74 | main.step( "Creating ONOS package" ) |
| 75 | packageResult = main.ONOSbench.onosPackage() |
Cameron Franke | 2ea90e5 | 2015-01-21 10:04:16 -0800 | [diff] [blame] | 76 | |
andrew@onlab.us | c400b11 | 2015-01-21 15:33:19 -0800 | [diff] [blame] | 77 | main.step( "Installing ONOS package" ) |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 78 | install1Result = main.ONOSbench.onosInstall( node=ONOSIp[1] ) |
Cameron Franke | 2ea90e5 | 2015-01-21 10:04:16 -0800 | [diff] [blame] | 79 | |
andrew@onlab.us | c400b11 | 2015-01-21 15:33:19 -0800 | [diff] [blame] | 80 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 81 | main.step( "Applying cell file to environment" ) |
| 82 | cellApplyResult = main.ONOSbench.setCell( cellName ) |
| 83 | main.step( "verify cells" ) |
| 84 | verifyCellResult = main.ONOSbench.verifyCell() |
Cameron Franke | 2ea90e5 | 2015-01-21 10:04:16 -0800 | [diff] [blame] | 85 | |
andrew@onlab.us | c400b11 | 2015-01-21 15:33:19 -0800 | [diff] [blame] | 86 | main.step( "Set cell for ONOS cli env" ) |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 87 | cli1 = main.ONOS1cli.startOnosCli( ONOSIp[1] ) |
Cameron Franke | 2ea90e5 | 2015-01-21 10:04:16 -0800 | [diff] [blame] | 88 | |
andrew@onlab.us | c400b11 | 2015-01-21 15:33:19 -0800 | [diff] [blame] | 89 | def CASE2( self, main ): |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 90 | # This case increases the cluster size by whatever scale is |
| 91 | # Note: 'scale' is the size of the step |
| 92 | # if scaling is not a part of your test, simply run this case |
| 93 | # once after CASE1 to set up your enviornment for your desired |
| 94 | # cluster size. If scaling is a part of you test call this case each time |
| 95 | # you want to increase cluster size |
| 96 | |
| 97 | '' |
andrew@onlab.us | c400b11 | 2015-01-21 15:33:19 -0800 | [diff] [blame] | 98 | 'Increase number of nodes and initiate CLI' |
| 99 | '' |
| 100 | import time |
andrew@onlab.us | c400b11 | 2015-01-21 15:33:19 -0800 | [diff] [blame] | 101 | global clusterCount |
| 102 | |
andrew@onlab.us | c400b11 | 2015-01-21 15:33:19 -0800 | [diff] [blame] | 103 | scale = int( main.params[ 'SCALE' ] ) |
andrew@onlab.us | c400b11 | 2015-01-21 15:33:19 -0800 | [diff] [blame] | 104 | clusterCount += scale |
| 105 | |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 106 | main.log.report( "Increasing cluster size to " + str( clusterCount ) ) |
| 107 | for node in range((clusterCount - scale) + 1, clusterCount + 1): |
| 108 | main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node]) |
| 109 | main.ONOSbench.onosInstall( ONOSIp[node]) |
| 110 | exec "a = main.ONOS%scli.startOnosCli" %str(node) |
| 111 | a(ONOSIp[node]) |
| 112 | |