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 | |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame^] | 11 | class SingleFunc: |
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 | |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame^] | 16 | def CASE1( self, main ): |
| 17 | import time |
| 18 | global init |
cameron@onlab.us | a54c1d7 | 2015-03-30 13:25:29 -0700 | [diff] [blame] | 19 | try: |
| 20 | if type(init) is not bool: |
| 21 | init = False |
| 22 | except NameError: |
| 23 | init = False |
| 24 | |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 25 | #Load values from params file |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame^] | 26 | checkoutBranch = main.params[ 'GIT' ][ 'branch' ] |
| 27 | gitPull = main.params[ 'GIT' ][ 'pull' ] |
andrew@onlab.us | c400b11 | 2015-01-21 15:33:19 -0800 | [diff] [blame] | 28 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
cameron@onlab.us | a54c1d7 | 2015-03-30 13:25:29 -0700 | [diff] [blame] | 29 | Apps = main.params[ 'ENV' ][ 'cellApps' ] |
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 | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 32 | maxNodes = int(main.params[ 'availableNodes' ]) |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame^] | 33 | skipMvn = main.params[ 'skipCleanInstall' ] |
cameron@onlab.us | a54c1d7 | 2015-03-30 13:25:29 -0700 | [diff] [blame] | 34 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
andrew@onlab.us | c400b11 | 2015-01-21 15:33:19 -0800 | [diff] [blame] | 35 | |
cameron@onlab.us | a54c1d7 | 2015-03-30 13:25:29 -0700 | [diff] [blame] | 36 | # -- INIT SECTION, ONLY RUNS ONCE -- # |
| 37 | if init == False: |
| 38 | init = True |
| 39 | global clusterCount #number of nodes running |
| 40 | global ONOSIp #list of ONOS IP addresses |
| 41 | global scale |
| 42 | |
| 43 | clusterCount = 0 |
| 44 | ONOSIp = [ 0 ] |
| 45 | scale = (main.params[ 'SCALE' ]).split(",") |
| 46 | clusterCount = int(scale[0]) |
andrew@onlab.us | f0dc9bb | 2015-03-11 15:13:44 -0700 | [diff] [blame] | 47 | |
cameron@onlab.us | a54c1d7 | 2015-03-30 13:25:29 -0700 | [diff] [blame] | 48 | #Populate ONOSIp with ips from params |
| 49 | for i in range(1, maxNodes + 1): |
| 50 | ipString = 'ip' + str(i) |
| 51 | ONOSIp.append(main.params[ 'CTRL' ][ ipString ]) |
| 52 | |
| 53 | #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test |
| 54 | if skipMvn != "yes": |
| 55 | mvnResult = main.ONOSbench.cleanInstall() |
andrew@onlab.us | f0dc9bb | 2015-03-11 15:13:44 -0700 | [diff] [blame] | 56 | |
andrew@onlab.us | f0dc9bb | 2015-03-11 15:13:44 -0700 | [diff] [blame] | 57 | #git |
| 58 | main.step( "Git checkout and pull " + checkoutBranch ) |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame^] | 59 | if gitPull == 'True': |
andrew@onlab.us | f0dc9bb | 2015-03-11 15:13:44 -0700 | [diff] [blame] | 60 | checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch ) |
| 61 | pullResult = main.ONOSbench.gitPull() |
Cameron Franke | 2ea90e5 | 2015-01-21 10:04:16 -0800 | [diff] [blame] | 62 | |
andrew@onlab.us | f0dc9bb | 2015-03-11 15:13:44 -0700 | [diff] [blame] | 63 | else: |
| 64 | checkoutResult = main.TRUE |
| 65 | pullResult = main.TRUE |
| 66 | main.log.info( "Skipped git checkout and pull" ) |
cameron@onlab.us | a54c1d7 | 2015-03-30 13:25:29 -0700 | [diff] [blame] | 67 | |
| 68 | # -- END OF INIT SECTION --# |
| 69 | |
| 70 | clusterCount = int(scale[0]) |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame^] | 71 | scale.remove(scale[0]) |
cameron@onlab.us | a54c1d7 | 2015-03-30 13:25:29 -0700 | [diff] [blame] | 72 | |
| 73 | #kill off all onos processes |
| 74 | main.log.step("Safety check, killing all ONOS processes") |
| 75 | main.log.step("before initiating enviornment setup") |
| 76 | for node in range(1, maxNodes + 1): |
| 77 | main.ONOSbench.onosDie(ONOSIp[node]) |
| 78 | |
| 79 | #Uninstall everywhere |
| 80 | main.log.step( "Cleaning Enviornment..." ) |
| 81 | for i in range(1, maxNodes + 1): |
| 82 | main.log.info(" Uninstalling ONOS " + str(i) ) |
| 83 | main.ONOSbench.onosUninstall( ONOSIp[i] ) |
| 84 | |
| 85 | #construct the cell file |
| 86 | main.log.info("Creating cell file") |
| 87 | cellIp = [] |
| 88 | for node in range (1, clusterCount + 1): |
| 89 | cellIp.append(ONOSIp[node]) |
andrew@onlab.us | f0dc9bb | 2015-03-11 15:13:44 -0700 | [diff] [blame] | 90 | |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame^] | 91 | main.ONOSbench.createCellFile(BENCHIp,cellName,"",str(Apps), *cellIp) |
andrew@onlab.us | f0dc9bb | 2015-03-11 15:13:44 -0700 | [diff] [blame] | 92 | |
cameron@onlab.us | 96a9fab | 2015-03-31 09:22:49 -0700 | [diff] [blame] | 93 | main.step( "Set Cell" ) |
| 94 | main.ONOSbench.setCell(cellName) |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 95 | |
andrew@onlab.us | c400b11 | 2015-01-21 15:33:19 -0800 | [diff] [blame] | 96 | main.step( "Creating ONOS package" ) |
| 97 | packageResult = main.ONOSbench.onosPackage() |
Cameron Franke | 2ea90e5 | 2015-01-21 10:04:16 -0800 | [diff] [blame] | 98 | |
andrew@onlab.us | c400b11 | 2015-01-21 15:33:19 -0800 | [diff] [blame] | 99 | main.step( "verify cells" ) |
| 100 | verifyCellResult = main.ONOSbench.verifyCell() |
cameron@onlab.us | dead405 | 2015-04-01 16:12:56 -0700 | [diff] [blame] | 101 | |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame^] | 102 | main.log.report( "Initializing " + str( clusterCount ) + " node cluster." ) |
cameron@onlab.us | a54c1d7 | 2015-03-30 13:25:29 -0700 | [diff] [blame] | 103 | for node in range(1, clusterCount + 1): |
| 104 | main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node]) |
| 105 | main.ONOSbench.onosInstall( ONOSIp[node]) |
Cameron Franke | 2ea90e5 | 2015-01-21 10:04:16 -0800 | [diff] [blame] | 106 | |
cameron@onlab.us | a54c1d7 | 2015-03-30 13:25:29 -0700 | [diff] [blame] | 107 | for node in range(1, clusterCount + 1): |
| 108 | for i in range( 2 ): |
| 109 | isup = main.ONOSbench.isup( ONOSIp[node] ) |
| 110 | if isup: |
| 111 | main.log.info("ONOS " + str(node) + " is up\n") |
| 112 | break |
| 113 | if not isup: |
| 114 | main.log.report( "ONOS " + str(node) + " didn't start!" ) |
| 115 | main.log.info("Startup sequence complete") |
Cameron Franke | 2ea90e5 | 2015-01-21 10:04:16 -0800 | [diff] [blame] | 116 | |
andrew@onlab.us | c400b11 | 2015-01-21 15:33:19 -0800 | [diff] [blame] | 117 | def CASE2( self, main ): |
andrew@onlab.us | f0dc9bb | 2015-03-11 15:13:44 -0700 | [diff] [blame] | 118 | |
cameron@onlab.us | a54c1d7 | 2015-03-30 13:25:29 -0700 | [diff] [blame] | 119 | print ("clusterCount: " + str(clusterCount)) |
| 120 | print ("scale: " + str(scale)) |
| 121 | print ("ONOSIp: " + str(ONOSIp)) |
| 122 | print ("INIT: " + str(init)) |
| 123 | |