blob: c2901553033cbd79effb86976ac0acc2077321ec [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
cameron@onlab.usa54c1d72015-03-30 13:25:29 -070019 global init
20 try:
21 if type(init) is not bool:
22 init = False
23 except NameError:
24 init = False
25
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' ]
cameron@onlab.usa54c1d72015-03-30 13:25:29 -070030 Apps = main.params[ 'ENV' ][ 'cellApps' ]
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' ])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080035 skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
cameron@onlab.usa54c1d72015-03-30 13:25:29 -070036 cellName = main.params[ 'ENV' ][ 'cellName' ]
andrew@onlab.usc400b112015-01-21 15:33:19 -080037
cameron@onlab.usa54c1d72015-03-30 13:25:29 -070038 # -- 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.usf0dc9bb2015-03-11 15:13:44 -070049
cameron@onlab.usa54c1d72015-03-30 13:25:29 -070050 #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.usf0dc9bb2015-03-11 15:13:44 -070058
andrew@onlab.usf0dc9bb2015-03-11 15:13:44 -070059 #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 Franke2ea90e52015-01-21 10:04:16 -080064
andrew@onlab.usf0dc9bb2015-03-11 15:13:44 -070065 else:
66 checkoutResult = main.TRUE
67 pullResult = main.TRUE
68 main.log.info( "Skipped git checkout and pull" )
cameron@onlab.usa54c1d72015-03-30 13:25:29 -070069
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.usf0dc9bb2015-03-11 15:13:44 -070092
cameron@onlab.usa54c1d72015-03-30 13:25:29 -070093 main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp)
andrew@onlab.usf0dc9bb2015-03-11 15:13:44 -070094
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.usa54c1d72015-03-30 13:25:29 -0700101
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 Franke2ea90e52015-01-21 10:04:16 -0800105
cameron@onlab.usa54c1d72015-03-30 13:25:29 -0700106 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 Franke2ea90e52015-01-21 10:04:16 -0800115
andrew@onlab.usc400b112015-01-21 15:33:19 -0800116 def CASE2( self, main ):
andrew@onlab.usf0dc9bb2015-03-11 15:13:44 -0700117
cameron@onlab.usa54c1d72015-03-30 13:25:29 -0700118 print ("clusterCount: " + str(clusterCount))
119 print ("scale: " + str(scale))
120 print ("ONOSIp: " + str(ONOSIp))
121 print ("INIT: " + str(init))
122