blob: a8d21d227c5d8e41d9481971de6da5790fbd6ff7 [file] [log] [blame]
jenkins15b2b132015-06-23 14:04:09 -07001# ScaleOutTemplate
2#
3# CASE1 starts number of nodes specified in param file
4#
5# cameron@onlab.us
6
7import sys
8import os.path
9
10
11class ScaleOutTemplate:
12
13 def __init__( self ):
14 self.default = ''
15
16 def CASE1( self, main ):
17
18 import time
19 global init
20
21 try:
22 if type(init) is not bool:
23 init = False
24 except NameError:
25 init = False
26
27 #Load values from params file
28 checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
29 gitPull = main.params[ 'GIT' ][ 'autopull' ]
30 cellName = main.params[ 'ENV' ][ 'cellName' ]
31 Apps = main.params[ 'ENV' ][ 'cellApps' ]
32 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
33 maxNodes = int(main.params[ 'availableNodes' ])
34 skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
35 cellName = main.params[ 'ENV' ][ 'cellName' ]
36
37 # -- INIT SECTION, ONLY RUNS ONCE -- #
38 if init == False:
39 init = True
40 global clusterCount #number of nodes running
41 global ONOSIp #list of ONOS IP addresses
42 global scale
43
44 clusterCount = 0
45 ONOSIp = [ 0 ]
46 scale = (main.params[ 'SCALE' ]).split(",")
47 clusterCount = int(scale[0])
48
49 #Populate ONOSIp with ips from params
50 ONOSIp = [0]
51 ONOSIp.extend(main.ONOSbench.getOnosIps())
52 MN1Ip = ONOSIp[len(ONOSIp) -1]
53 BENCHIp = ONOSIp[len(ONOSIp) -2]
54
55 #git
56 main.step( "Git checkout and pull " + checkoutBranch )
57 if gitPull == 'on':
58 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
59 pullResult = main.ONOSbench.gitPull()
60 else:
61 main.log.info( "Skipped git checkout and pull" )
62
63 if skipMvn != "yes":
64 mvnResult = main.ONOSbench.cleanInstall()
65
66 # -- END OF INIT SECTION --#
67
68 clusterCount = int(scale[0])
69 scale.remove(scale[0])
70
71 #kill off all onos processes
72 main.log.step("Safety check, killing all ONOS processes")
73 main.log.step("before initiating enviornment setup")
74 for node in range(1, maxNodes + 1):
75 main.ONOSbench.onosDie(ONOSIp[node])
76
77 #Uninstall everywhere
78 main.log.step( "Cleaning Enviornment..." )
79 for i in range(1, maxNodes + 1):
80 main.log.info(" Uninstalling ONOS " + str(i) )
81 main.ONOSbench.onosUninstall( ONOSIp[i] )
82
83 #construct the cell file
84 main.log.info("Creating cell file")
85 cellIp = []
86 for node in range (1, clusterCount + 1):
87 cellIp.append(ONOSIp[node])
88
89 main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp)
90
91 main.step( "Set Cell" )
92 main.ONOSbench.setCell(cellName)
93
94 main.step( "Creating ONOS package" )
95 packageResult = main.ONOSbench.onosPackage()
96
97 main.step( "verify cells" )
98 verifyCellResult = main.ONOSbench.verifyCell()
99
100 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
101 for node in range(1, clusterCount + 1):
102 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
103 main.ONOSbench.onosInstall( ONOSIp[node])
104
105 for node in range(1, clusterCount + 1):
106 for i in range( 2 ):
107 isup = main.ONOSbench.isup( ONOSIp[node] )
108 if isup:
109 main.log.info("ONOS " + str(node) + " is up\n")
110 break
111 if not isup:
112 main.log.report( "ONOS " + str(node) + " didn't start!" )
113 main.log.info("Startup sequence complete")
114
115 def CASE2( self, main ):
116
117 print ("clusterCount: " + str(clusterCount))
118 print ("scale: " + str(scale))
119 print ("ONOSIp: " + str(ONOSIp))
120 print ("INIT: " + str(init))
121