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