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