blob: e991dee574f6d8fb142e396dc8499c9d90115ace [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
kelvin-onlabf70fd542015-05-07 18:41:40 -070011class SingleFunc:
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
kelvin-onlabf70fd542015-05-07 18:41:40 -070016 def CASE1( self, main ):
17 import time
18 global init
cameron@onlab.usa54c1d72015-03-30 13:25:29 -070019 try:
20 if type(init) is not bool:
21 init = False
22 except NameError:
23 init = False
24
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080025 #Load values from params file
kelvin-onlabf70fd542015-05-07 18:41:40 -070026 checkoutBranch = main.params[ 'GIT' ][ 'branch' ]
27 gitPull = main.params[ 'GIT' ][ 'pull' ]
andrew@onlab.usc400b112015-01-21 15:33:19 -080028 cellName = main.params[ 'ENV' ][ 'cellName' ]
cameron@onlab.usa54c1d72015-03-30 13:25:29 -070029 Apps = main.params[ 'ENV' ][ 'cellApps' ]
andrew@onlab.usc400b112015-01-21 15:33:19 -080030 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
31 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080032 maxNodes = int(main.params[ 'availableNodes' ])
kelvin-onlabf70fd542015-05-07 18:41:40 -070033 skipMvn = main.params[ 'skipCleanInstall' ]
cameron@onlab.usa54c1d72015-03-30 13:25:29 -070034 cellName = main.params[ 'ENV' ][ 'cellName' ]
andrew@onlab.usc400b112015-01-21 15:33:19 -080035
cameron@onlab.usa54c1d72015-03-30 13:25:29 -070036 # -- 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.usf0dc9bb2015-03-11 15:13:44 -070047
cameron@onlab.usa54c1d72015-03-30 13:25:29 -070048 #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.usf0dc9bb2015-03-11 15:13:44 -070056
andrew@onlab.usf0dc9bb2015-03-11 15:13:44 -070057 #git
58 main.step( "Git checkout and pull " + checkoutBranch )
kelvin-onlabf70fd542015-05-07 18:41:40 -070059 if gitPull == 'True':
andrew@onlab.usf0dc9bb2015-03-11 15:13:44 -070060 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
61 pullResult = main.ONOSbench.gitPull()
Cameron Franke2ea90e52015-01-21 10:04:16 -080062
andrew@onlab.usf0dc9bb2015-03-11 15:13:44 -070063 else:
64 checkoutResult = main.TRUE
65 pullResult = main.TRUE
66 main.log.info( "Skipped git checkout and pull" )
cameron@onlab.usa54c1d72015-03-30 13:25:29 -070067
68 # -- END OF INIT SECTION --#
69
70 clusterCount = int(scale[0])
kelvin-onlabf70fd542015-05-07 18:41:40 -070071 scale.remove(scale[0])
cameron@onlab.usa54c1d72015-03-30 13:25:29 -070072
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.usf0dc9bb2015-03-11 15:13:44 -070090
kelvin-onlabf70fd542015-05-07 18:41:40 -070091 main.ONOSbench.createCellFile(BENCHIp,cellName,"",str(Apps), *cellIp)
andrew@onlab.usf0dc9bb2015-03-11 15:13:44 -070092
cameron@onlab.us96a9fab2015-03-31 09:22:49 -070093 main.step( "Set Cell" )
94 main.ONOSbench.setCell(cellName)
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080095
andrew@onlab.usc400b112015-01-21 15:33:19 -080096 main.step( "Creating ONOS package" )
97 packageResult = main.ONOSbench.onosPackage()
Cameron Franke2ea90e52015-01-21 10:04:16 -080098
andrew@onlab.usc400b112015-01-21 15:33:19 -080099 main.step( "verify cells" )
100 verifyCellResult = main.ONOSbench.verifyCell()
cameron@onlab.usdead4052015-04-01 16:12:56 -0700101
kelvin-onlabf70fd542015-05-07 18:41:40 -0700102 main.log.report( "Initializing " + str( clusterCount ) + " node cluster." )
cameron@onlab.usa54c1d72015-03-30 13:25:29 -0700103 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 Franke2ea90e52015-01-21 10:04:16 -0800106
cameron@onlab.usa54c1d72015-03-30 13:25:29 -0700107 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 Franke2ea90e52015-01-21 10:04:16 -0800116
andrew@onlab.usc400b112015-01-21 15:33:19 -0800117 def CASE2( self, main ):
andrew@onlab.usf0dc9bb2015-03-11 15:13:44 -0700118
cameron@onlab.usa54c1d72015-03-30 13:25:29 -0700119 print ("clusterCount: " + str(clusterCount))
120 print ("scale: " + str(scale))
121 print ("ONOSIp: " + str(ONOSIp))
122 print ("INIT: " + str(init))
123