blob: abdc78c50885c408977cef3a63c0c903a1268c86 [file] [log] [blame]
Cameron Franke2ea90e52015-01-21 10:04:16 -08001# ScaleOutTemplate
2#
3# CASE1 starts number of nodes specified in param file
4#
5# cameron@onlab.us
6
andrew@onlab.usc400b112015-01-21 15:33:19 -08007import sys
8import os
Cameron Franke2ea90e52015-01-21 10:04:16 -08009
10
11class ScaleOutTemplate:
andrew@onlab.usc400b112015-01-21 15:33:19 -080012
13 def __init__( self ):
Cameron Franke2ea90e52015-01-21 10:04:16 -080014 self.default = ''
Cameron Franke2ea90e52015-01-21 10:04:16 -080015
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080016 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.usc400b112015-01-21 15:33:19 -080022 clusterCount = 1
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080023 ONOSIp = [ 0 ]
andrew@onlab.usc400b112015-01-21 15:33:19 -080024
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080025 #Load values from params file
andrew@onlab.usc400b112015-01-21 15:33:19 -080026 checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
27 gitPull = main.params[ 'GIT' ][ 'autopull' ]
28 cellName = main.params[ 'ENV' ][ 'cellName' ]
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080029 Features= main.params[ 'ENV' ][ 'cellFeatures' ]
andrew@onlab.usc400b112015-01-21 15:33:19 -080030 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
31 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
andrew@onlab.usc400b112015-01-21 15:33:19 -080032 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080033 maxNodes = int(main.params[ 'availableNodes' ])
34 Features = main.params[ 'ENV' ][ 'cellFeatures' ]
35 skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
andrew@onlab.usc400b112015-01-21 15:33:19 -080036
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080037 #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.usc400b112015-01-21 15:33:19 -080051 main.log.step( "Cleaning Enviornment..." )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080052 for i in range(1, maxNodes + 1):
53 main.log.info(" Uninstalling ONOS " + str(i) )
54 main.ONOSbench.onosUninstall( ONOSIp[i] )
andrew@onlab.usc400b112015-01-21 15:33:19 -080055
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080056 #git
andrew@onlab.usc400b112015-01-21 15:33:19 -080057 main.step( "Git checkout and pull " + checkoutBranch )
58 if gitPull == 'on':
59 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
60 pullResult = main.ONOSbench.gitPull()
61
Cameron Franke2ea90e52015-01-21 10:04:16 -080062 else:
andrew@onlab.usc400b112015-01-21 15:33:19 -080063 checkoutResult = main.TRUE
64 pullResult = main.TRUE
65 main.log.info( "Skipped git checkout and pull" )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080066
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 Franke2ea90e52015-01-21 10:04:16 -080070
andrew@onlab.usc400b112015-01-21 15:33:19 -080071 main.step( "Set cell for ONOS cli env" )
72 main.ONOS1cli.setCell( cellName )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080073
andrew@onlab.usc400b112015-01-21 15:33:19 -080074 main.step( "Creating ONOS package" )
75 packageResult = main.ONOSbench.onosPackage()
Cameron Franke2ea90e52015-01-21 10:04:16 -080076
andrew@onlab.usc400b112015-01-21 15:33:19 -080077 main.step( "Installing ONOS package" )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080078 install1Result = main.ONOSbench.onosInstall( node=ONOSIp[1] )
Cameron Franke2ea90e52015-01-21 10:04:16 -080079
andrew@onlab.usc400b112015-01-21 15:33:19 -080080 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 Franke2ea90e52015-01-21 10:04:16 -080085
andrew@onlab.usc400b112015-01-21 15:33:19 -080086 main.step( "Set cell for ONOS cli env" )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080087 cli1 = main.ONOS1cli.startOnosCli( ONOSIp[1] )
Cameron Franke2ea90e52015-01-21 10:04:16 -080088
andrew@onlab.usc400b112015-01-21 15:33:19 -080089 def CASE2( self, main ):
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080090 # 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.usc400b112015-01-21 15:33:19 -080098 'Increase number of nodes and initiate CLI'
99 ''
100 import time
andrew@onlab.usc400b112015-01-21 15:33:19 -0800101 global clusterCount
102
andrew@onlab.usc400b112015-01-21 15:33:19 -0800103 scale = int( main.params[ 'SCALE' ] )
andrew@onlab.usc400b112015-01-21 15:33:19 -0800104 clusterCount += scale
105
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800106 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