blob: fdcd680f29a35123215a7cdf2bfc9e38458ef766 [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
andrew@onlab.usf0dc9bb2015-03-11 15:13:44 -07008import os.path
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
andrew@onlab.usf0dc9bb2015-03-11 15:13:44 -070018 import time #but only node 1 is started in this case
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080019
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.usf0dc9bb2015-03-11 15:13:44 -070025
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080026 #Load values from params file
andrew@onlab.usc400b112015-01-21 15:33:19 -080027 checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
28 gitPull = main.params[ 'GIT' ][ 'autopull' ]
29 cellName = main.params[ 'ENV' ][ 'cellName' ]
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080030 Features= main.params[ 'ENV' ][ 'cellFeatures' ]
andrew@onlab.usc400b112015-01-21 15:33:19 -080031 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
32 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
andrew@onlab.usc400b112015-01-21 15:33:19 -080033 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080034 maxNodes = int(main.params[ 'availableNodes' ])
35 Features = main.params[ 'ENV' ][ 'cellFeatures' ]
36 skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
andrew@onlab.usc400b112015-01-21 15:33:19 -080037
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080038 #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.usf0dc9bb2015-03-11 15:13:44 -070042
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.us2ae3a112015-02-02 11:24:32 -080058 #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.usc400b112015-01-21 15:33:19 -080067 main.log.step( "Cleaning Enviornment..." )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080068 for i in range(1, maxNodes + 1):
69 main.log.info(" Uninstalling ONOS " + str(i) )
70 main.ONOSbench.onosUninstall( ONOSIp[i] )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080071
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.usf0dc9bb2015-03-11 15:13:44 -070075
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 Franke2ea90e52015-01-21 10:04:16 -080081
andrew@onlab.usf0dc9bb2015-03-11 15:13:44 -070082 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.us2ae3a112015-02-02 11:24:32 -080090
andrew@onlab.usc400b112015-01-21 15:33:19 -080091 main.step( "Creating ONOS package" )
92 packageResult = main.ONOSbench.onosPackage()
Cameron Franke2ea90e52015-01-21 10:04:16 -080093
andrew@onlab.usc400b112015-01-21 15:33:19 -080094 main.step( "Installing ONOS package" )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080095 install1Result = main.ONOSbench.onosInstall( node=ONOSIp[1] )
Cameron Franke2ea90e52015-01-21 10:04:16 -080096
andrew@onlab.usc400b112015-01-21 15:33:19 -080097 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 Franke2ea90e52015-01-21 10:04:16 -0800102
andrew@onlab.usc400b112015-01-21 15:33:19 -0800103 main.step( "Set cell for ONOS cli env" )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800104 cli1 = main.ONOS1cli.startOnosCli( ONOSIp[1] )
Cameron Franke2ea90e52015-01-21 10:04:16 -0800105
andrew@onlab.usf0dc9bb2015-03-11 15:13:44 -0700106
andrew@onlab.usc400b112015-01-21 15:33:19 -0800107 def CASE2( self, main ):
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800108 # 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.usc400b112015-01-21 15:33:19 -0800116 'Increase number of nodes and initiate CLI'
117 ''
118 import time
andrew@onlab.usc400b112015-01-21 15:33:19 -0800119 global clusterCount
andrew@onlab.usf0dc9bb2015-03-11 15:13:44 -0700120
121 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
andrew@onlab.usc400b112015-01-21 15:33:19 -0800122 scale = int( main.params[ 'SCALE' ] )
andrew@onlab.usc400b112015-01-21 15:33:19 -0800123 clusterCount += scale
124
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800125 main.log.report( "Increasing cluster size to " + str( clusterCount ) )
126 for node in range((clusterCount - scale) + 1, clusterCount + 1):
andrew@onlab.usf0dc9bb2015-03-11 15:13:44 -0700127 main.ONOSbench.onosDie(ONOSIp[node])
128 time.sleep(10)
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800129 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
andrew@onlab.usf0dc9bb2015-03-11 15:13:44 -0700130 main.ONOSbench.onosInstall( node=ONOSIp[node])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800131 exec "a = main.ONOS%scli.startOnosCli" %str(node)
132 a(ONOSIp[node])
andrew@onlab.usf0dc9bb2015-03-11 15:13:44 -0700133
134