blob: d10b17fb807efce3d8dd24f560ee8afe7898813b [file] [log] [blame]
Jon Hallca319892017-06-15 15:25:22 -07001#!/usr/bin/env python
2"""
Jeremy Ronquillo4d5f1d02017-10-13 20:23:57 +00003Copyright 2017 Open Networking Foundation (ONF)
Jon Hallca319892017-06-15 15:25:22 -07004
5Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
6the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
7or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
8
9 TestON is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 2 of the License, or
Jeremy Ronquillo4d5f1d02017-10-13 20:23:57 +000012 (at your option) any later version.
Jon Hallca319892017-06-15 15:25:22 -070013
14 TestON is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with TestON. If not, see <http://www.gnu.org/licenses/>.
21
22
23This driver is used to interact with an ONOS cluster. It should
24handle creating the necessary components to interact with each specific ONOS nodes.
25
26Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
27the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
28or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
29
30"""
31import pexpect
32import os
33from drivers.common.clidriver import CLI
34
35# FIXME: Move this to it's own file?
36class Controller():
Jeremy Ronquillo82705492017-10-18 14:19:55 -070037
Jon Hallca319892017-06-15 15:25:22 -070038 def __str__( self ):
39 return self.name
Jeremy Ronquillo82705492017-10-18 14:19:55 -070040
Jon Hallca319892017-06-15 15:25:22 -070041 def __repr__( self ):
Jeremy Ronquillo82705492017-10-18 14:19:55 -070042 # TODO use repr() for components?
Jon Hallca319892017-06-15 15:25:22 -070043 return "%s<IP=%s, CLI=%s, REST=%s, Bench=%s >" % ( self.name,
Jon Hall4173b242017-09-12 17:04:38 -070044 self.ipAddress,
45 self.CLI,
46 self.REST,
47 self.Bench )
Jon Hallca319892017-06-15 15:25:22 -070048
49 def __getattr__( self, name ):
50 """
51 Called when an attribute lookup has not found the attribute
Jeremy Ronquillo4d5f1d02017-10-13 20:23:57 +000052 in the usual places (i.e. it is not an instance attribute nor
53 is it found in the class tree for self). name is the attribute
54 name. This method should return the (computed) attribute value
Jon Hallca319892017-06-15 15:25:22 -070055 or raise an AttributeError exception.
56
57 We will look into each of the node's component handles to try to find the attreibute, looking at REST first
58 """
59 if hasattr( self.REST, name ):
Jon Hall3c0114c2020-08-11 15:07:42 -070060 main.log.debug( "%s: Using Rest driver's attribute for '%s'" % ( self.name, name ) )
61 return getattr( self.REST, name )
Jon Hallca319892017-06-15 15:25:22 -070062 if hasattr( self.CLI, name ):
Jon Hall3c0114c2020-08-11 15:07:42 -070063 main.log.debug( "%s: Using CLI driver's attribute for '%s'" % ( self.name, name ) )
64 return getattr( self.CLI, name )
Jon Hallca319892017-06-15 15:25:22 -070065 if hasattr( self.Bench, name ):
Jon Hall3c0114c2020-08-11 15:07:42 -070066 main.log.debug( "%s: Using Bench driver's attribute for '%s'" % ( self.name, name ) )
67 return getattr( self.Bench, name )
Devin Lim142b5342017-07-20 15:22:39 -070068 raise AttributeError( "Could not find the attribute %s in %r or it's component handles" % ( name, self ) )
Jon Hallca319892017-06-15 15:25:22 -070069
Jon Hall3c0114c2020-08-11 15:07:42 -070070 def __init__( self, name, ipAddress, CLI=None, REST=None, Bench=None, pos=None,
Jon Hall06fd0df2021-01-25 15:50:06 -080071 userName=None, server=None, k8s=None, dockerPrompt=None ):
Jeremy Ronquillo82705492017-10-18 14:19:55 -070072 # TODO: validate these arguments
Jon Hallca319892017-06-15 15:25:22 -070073 self.name = str( name )
74 self.ipAddress = ipAddress
75 self.CLI = CLI
76 self.REST = REST
77 self.Bench = Bench
78 self.active = False
Devin Lim142b5342017-07-20 15:22:39 -070079 self.pos = pos
80 self.ip_address = ipAddress
81 self.user_name = userName
Jon Hall4173b242017-09-12 17:04:38 -070082 self.server = server
Jon Hall06fd0df2021-01-25 15:50:06 -080083 self.k8s = k8s
Jon Hall3c0114c2020-08-11 15:07:42 -070084 self.dockerPrompt = dockerPrompt
Jon Hallca319892017-06-15 15:25:22 -070085
86class OnosClusterDriver( CLI ):
87
88 def __init__( self ):
89 """
90 Initialize client
91 """
92 self.name = None
93 self.home = None
94 self.handle = None
Jon Hall3c0114c2020-08-11 15:07:42 -070095 self.useDocker = False
96 self.dockerPrompt = None
Jon Halle37bd1f2020-09-10 12:16:41 -070097 self.maxNodes = None
Jon Hall06fd0df2021-01-25 15:50:06 -080098 self.kubeConfig = None
Jon Hallca319892017-06-15 15:25:22 -070099 self.nodes = []
100 super( OnosClusterDriver, self ).__init__()
101
Jon Hallca319892017-06-15 15:25:22 -0700102 def connect( self, **connectargs ):
103 """
104 Creates ssh handle for ONOS "bench".
105 NOTE:
106 The ip_address would come from the topo file using the host tag, the
107 value can be an environment variable as well as a "localhost" to get
108 the ip address needed to ssh to the "bench"
109 """
110 try:
111 for key in connectargs:
112 vars( self )[ key ] = connectargs[ key ]
113 self.home = "~/onos"
114 for key in self.options:
115 if key == "home":
Jon Halle37bd1f2020-09-10 12:16:41 -0700116 self.home = self.options[ key ]
Jon Hallca319892017-06-15 15:25:22 -0700117 elif key == "karaf_username":
118 self.karafUser = self.options[ key ]
119 elif key == "karaf_password":
120 self.karafPass = self.options[ key ]
121 elif key == "cluster_name":
122 prefix = self.options[ key ]
Jon Hall3c0114c2020-08-11 15:07:42 -0700123 elif key == "useDocker":
124 self.useDocker = "True" == self.options[ key ]
125 elif key == "docker_prompt":
126 self.dockerPrompt = self.options[ key ]
Jon Hall9b0de1f2020-08-24 15:38:04 -0700127 elif key == "web_user":
128 self.webUser = self.options[ key ]
129 elif key == "web_pass":
130 self.webPass = self.options[ key ]
Jon Halle37bd1f2020-09-10 12:16:41 -0700131 elif key == "nodes":
132 # Maximum number of ONOS nodes to run, if there is any
133 self.maxNodes = self.options[ key ]
Jon Hall06fd0df2021-01-25 15:50:06 -0800134 elif key == "kubeConfig":
135 self.kubeConfig = self.options[ key ]
Jon Hallca319892017-06-15 15:25:22 -0700136
Jon Hall0e240372018-05-02 11:21:57 -0700137 self.home = self.checkOptions( self.home, "~/onos" )
138 self.karafUser = self.checkOptions( self.karafUser, self.user_name )
139 self.karafPass = self.checkOptions( self.karafPass, self.pwd )
Jon Hall9b0de1f2020-08-24 15:38:04 -0700140 self.webUser = self.checkOptions( self.webUser, "onos" )
141 self.webPass = self.checkOptions( self.webPass, "rocks" )
Jon Hallca319892017-06-15 15:25:22 -0700142 prefix = self.checkOptions( prefix, "ONOS" )
Jon Hall3c0114c2020-08-11 15:07:42 -0700143 self.useDocker = self.checkOptions( self.useDocker, False )
144 self.dockerPrompt = self.checkOptions( self.dockerPrompt, "~/onos#" )
Jon Halle37bd1f2020-09-10 12:16:41 -0700145 self.maxNodes = int( self.checkOptions( self.maxNodes, 100 ) )
Jon Hall06fd0df2021-01-25 15:50:06 -0800146 self.kubeConfig = self.checkOptions( self.kubeConfig, None )
Jon Hallca319892017-06-15 15:25:22 -0700147
148 self.name = self.options[ 'name' ]
149
Jon Hallca319892017-06-15 15:25:22 -0700150
Jon Hall06fd0df2021-01-25 15:50:06 -0800151 if not self.kubeConfig:
152 # Grabs all OC environment variables based on max number of nodes
153 # TODO: Also support giving an ip range as a compononet option
154 self.onosIps = {} # Dictionary of all possible ONOS ip
155
156 try:
157 if self.maxNodes:
158 for i in range( self.maxNodes ):
159 envString = "OC" + str( i + 1 )
160 # If there is no more OC# then break the loop
161 if os.getenv( envString ):
162 self.onosIps[ envString ] = os.getenv( envString )
163 else:
164 self.maxNodes = len( self.onosIps )
165 main.log.info( self.name +
166 ": Created cluster data with " +
167 str( self.maxNodes ) +
168 " maximum number" +
169 " of nodes" )
170 break
171
172 if not self.onosIps:
173 main.log.info( "Could not read any environment variable"
174 + " please load a cell file with all" +
175 " onos IP" )
176 self.maxNodes = None
Jon Hallca319892017-06-15 15:25:22 -0700177 else:
Jon Hall06fd0df2021-01-25 15:50:06 -0800178 main.log.info( self.name + ": Found " +
179 str( self.onosIps.values() ) +
180 " ONOS IPs" )
181 except KeyError:
182 main.log.info( "Invalid environment variable" )
183 except Exception as inst:
184 main.log.error( "Uncaught exception: " + str( inst ) )
Jon Hallca319892017-06-15 15:25:22 -0700185 try:
186 if os.getenv( str( self.ip_address ) ) is not None:
187 self.ip_address = os.getenv( str( self.ip_address ) )
188 else:
189 main.log.info( self.name +
190 ": Trying to connect to " +
191 self.ip_address )
192 except KeyError:
193 main.log.info( "Invalid host name," +
194 " connecting to local host instead" )
195 self.ip_address = 'localhost'
196 except Exception as inst:
197 main.log.error( "Uncaught exception: " + str( inst ) )
198
199 self.handle = super( OnosClusterDriver, self ).connect(
200 user_name=self.user_name,
201 ip_address=self.ip_address,
202 port=self.port,
203 pwd=self.pwd,
204 home=self.home )
205
206 if self.handle:
207 self.handle.sendline( "cd " + self.home )
208 self.handle.expect( "\$" )
Jon Hall06fd0df2021-01-25 15:50:06 -0800209 if self.kubeConfig:
210 # Try to get # of onos nodes using given kubernetes configuration
211 names = self.kubectlGetPodNames( self.kubeConfig,
212 main.params[ 'kubernetes' ][ 'namespace' ],
213 main.params[ 'kubernetes' ][ 'appName' ] )
214 self.podNames = names
215 self.onosIps = {} # Dictionary of all possible ONOS ip
216 for i in range( 1, len( names ) + 1 ):
217 self.onosIps[ 'OC%i' % i ] = self.ip_address
218 self.maxNodes = len( names )
Jon Hallca319892017-06-15 15:25:22 -0700219 self.createComponents( prefix=prefix )
Jon Hall06fd0df2021-01-25 15:50:06 -0800220 if self.kubeConfig:
221 # Create Port Forwarding sessions for each controller
222 for node in self.nodes:
223 kubectl = node.k8s
224 index = self.nodes.index( node )
225 # Store each pod name in the k8s component
226 kubectl.podName = self.podNames[ index ]
227 # Setup port-forwarding and save the local port
228 guiPort = 8181
229 cliPort = 8101
230 portsList = ""
231 for port in [ guiPort, cliPort ]:
232 localPort = port + index + 1
233 portsList += "%s:%s " % ( localPort, port )
234 if port == cliPort:
235 node.CLI.karafPort = localPort
236 main.log.info( "Setting up port forward for pod %s: [ %s ]" % ( self.podNames[ index ], portsList ) )
237 pf = kubectl.kubectlPortForward( self.podNames[ index ],
238 portsList,
239 kubectl.kubeConfig,
240 main.params[ 'kubernetes' ][ 'namespace' ] )
241 if not pf:
242 main.log.error( "Failed to create port forwarding" )
243 return main.FALSE
Jon Hallca319892017-06-15 15:25:22 -0700244 return self.handle
245 else:
246 main.log.info( "Failed to create ONOS handle" )
247 return main.FALSE
248 except pexpect.EOF:
249 main.log.error( self.name + ": EOF exception found" )
250 main.log.error( self.name + ": " + self.handle.before )
Devin Lim44075962017-08-11 10:56:37 -0700251 main.cleanAndExit()
Jon Hallca319892017-06-15 15:25:22 -0700252 except Exception:
253 main.log.exception( self.name + ": Uncaught exception!" )
Devin Lim44075962017-08-11 10:56:37 -0700254 main.cleanAndExit()
Jon Hallca319892017-06-15 15:25:22 -0700255
256 def disconnect( self ):
257 """
258 Called when Test is complete to disconnect the ONOS handle.
259 """
260 response = main.TRUE
261 try:
262 if self.handle:
263 self.handle.sendline( "" )
264 self.handle.expect( "\$" )
265 self.handle.sendline( "exit" )
266 self.handle.expect( "closed" )
267 except pexpect.EOF:
268 main.log.error( self.name + ": EOF exception found" )
269 main.log.error( self.name + ": " + self.handle.before )
270 except ValueError:
271 main.log.exception( "Exception in disconnect of " + self.name )
272 response = main.TRUE
273 except Exception:
274 main.log.exception( self.name + ": Connection failed to the host" )
275 response = main.FALSE
276 return response
277
Devin Lim142b5342017-07-20 15:22:39 -0700278 def setCliOptions( self, name, host ):
Jon Hallca319892017-06-15 15:25:22 -0700279 """
280 Parse the cluster options to create an ONOS cli component with the given name
281 """
Jeremy Ronquillo4d5f1d02017-10-13 20:23:57 +0000282 main.componentDictionary[name] = main.componentDictionary[self.name].copy()
Devin Lim142b5342017-07-20 15:22:39 -0700283 clihost = main.componentDictionary[ name ][ 'COMPONENTS' ].get( "diff_clihost", "" )
284 if clihost == "True":
285 main.componentDictionary[ name ][ 'host' ] = host
Jon Hall06fd0df2021-01-25 15:50:06 -0800286 home = main.componentDictionary[name]['COMPONENTS'].get( "onos_home", None )
287 main.componentDictionary[name]['home'] = self.checkOptions( home, None )
Jeremy Ronquillo4d5f1d02017-10-13 20:23:57 +0000288 main.componentDictionary[name]['type'] = "OnosCliDriver"
289 main.componentDictionary[name]['connect_order'] = str( int( main.componentDictionary[name]['connect_order'] ) + 1 )
Jon Hallca319892017-06-15 15:25:22 -0700290
Devin Lim142b5342017-07-20 15:22:39 -0700291 def createCliComponent( self, name, host ):
Jon Hallca319892017-06-15 15:25:22 -0700292 """
293 Creates a new onos cli component.
294
295 Arguments:
296 name - The string of the name of this component. The new component
297 will be assigned to main.<name> .
298 In addition, main.<name>.name = str( name )
299 """
300 try:
301 # look to see if this component already exists
302 getattr( main, name )
303 except AttributeError:
304 # namespace is clear, creating component
Devin Lim142b5342017-07-20 15:22:39 -0700305 self.setCliOptions( name, host )
Jon Hallca319892017-06-15 15:25:22 -0700306 return main.componentInit( name )
307 except pexpect.EOF:
308 main.log.error( self.name + ": EOF exception found" )
309 main.log.error( self.name + ": " + self.handle.before )
Devin Lim44075962017-08-11 10:56:37 -0700310 main.cleanAndExit()
Jon Hallca319892017-06-15 15:25:22 -0700311 except Exception:
312 main.log.exception( self.name + ": Uncaught exception!" )
Devin Lim44075962017-08-11 10:56:37 -0700313 main.cleanAndExit()
Jon Hallca319892017-06-15 15:25:22 -0700314 else:
315 # namespace is not clear!
316 main.log.error( name + " component already exists!" )
Devin Lim44075962017-08-11 10:56:37 -0700317 main.cleanAndExit()
Jon Hallca319892017-06-15 15:25:22 -0700318
319 def setRestOptions( self, name, host ):
320 """
321 Parse the cluster options to create an ONOS cli component with the given name
322 """
Jeremy Ronquillo4d5f1d02017-10-13 20:23:57 +0000323 main.componentDictionary[name] = main.componentDictionary[self.name].copy()
Jeremy Ronquillo4d5f1d02017-10-13 20:23:57 +0000324 user = main.componentDictionary[name]['COMPONENTS'].get( "web_user", "onos" )
325 main.componentDictionary[name]['user'] = self.checkOptions( user, "onos" )
326 password = main.componentDictionary[name]['COMPONENTS'].get( "web_pass", "rocks" )
You Wangbef7ea12018-09-21 13:15:12 -0700327 main.componentDictionary[name]['password'] = self.checkOptions( password, "rocks" )
Jeremy Ronquillo4d5f1d02017-10-13 20:23:57 +0000328 main.componentDictionary[name]['host'] = host
329 port = main.componentDictionary[name]['COMPONENTS'].get( "rest_port", "8181" )
330 main.componentDictionary[name]['port'] = self.checkOptions( port, "8181" )
331 main.componentDictionary[name]['type'] = "OnosRestDriver"
332 main.componentDictionary[name]['connect_order'] = str( int( main.componentDictionary[name]['connect_order'] ) + 1 )
Jon Hallca319892017-06-15 15:25:22 -0700333
334 def createRestComponent( self, name, ipAddress ):
335 """
336 Creates a new onos rest component.
337
338 Arguments:
339 name - The string of the name of this component. The new component
340 will be assigned to main.<name> .
341 In addition, main.<name>.name = str( name )
342 """
343 try:
344 # look to see if this component already exists
345 getattr( main, name )
346 except AttributeError:
347 # namespace is clear, creating component
348 self.setRestOptions( name, ipAddress )
349 return main.componentInit( name )
350 except pexpect.EOF:
351 main.log.error( self.name + ": EOF exception found" )
352 main.log.error( self.name + ": " + self.handle.before )
Devin Lim44075962017-08-11 10:56:37 -0700353 main.cleanAndExit()
Jon Hallca319892017-06-15 15:25:22 -0700354 except Exception:
355 main.log.exception( self.name + ": Uncaught exception!" )
Devin Lim44075962017-08-11 10:56:37 -0700356 main.cleanAndExit()
Jon Hallca319892017-06-15 15:25:22 -0700357 else:
358 # namespace is not clear!
359 main.log.error( name + " component already exists!" )
Devin Lim44075962017-08-11 10:56:37 -0700360 main.cleanAndExit()
Jon Hallca319892017-06-15 15:25:22 -0700361
362 def setBenchOptions( self, name ):
363 """
364 Parse the cluster options to create an ONOS "bench" component with the given name
365 """
Jeremy Ronquillo4d5f1d02017-10-13 20:23:57 +0000366 main.componentDictionary[name] = main.componentDictionary[self.name].copy()
367 main.componentDictionary[name]['type'] = "OnosDriver"
368 home = main.componentDictionary[name]['COMPONENTS'].get( "onos_home", None )
369 main.componentDictionary[name]['home'] = self.checkOptions( home, None )
370 main.componentDictionary[name]['connect_order'] = str( int( main.componentDictionary[name]['connect_order'] ) + 1 )
Jon Hallca319892017-06-15 15:25:22 -0700371
372 def createBenchComponent( self, name ):
373 """
374 Creates a new onos "bench" component.
375
376 Arguments:
377 name - The string of the name of this component. The new component
378 will be assigned to main.<name> .
379 In addition, main.<name>.name = str( name )
380 """
381 try:
382 # look to see if this component already exists
383 getattr( main, name )
384 except AttributeError:
385 # namespace is clear, creating component
386 self.setBenchOptions( name )
387 return main.componentInit( name )
388 except pexpect.EOF:
389 main.log.error( self.name + ": EOF exception found" )
390 main.log.error( self.name + ": " + self.handle.before )
Devin Lim44075962017-08-11 10:56:37 -0700391 main.cleanAndExit()
Jon Hallca319892017-06-15 15:25:22 -0700392 except Exception:
393 main.log.exception( self.name + ": Uncaught exception!" )
Devin Lim44075962017-08-11 10:56:37 -0700394 main.cleanAndExit()
Jon Hallca319892017-06-15 15:25:22 -0700395 else:
396 # namespace is not clear!
397 main.log.error( name + " component already exists!" )
Devin Lim44075962017-08-11 10:56:37 -0700398 main.cleanAndExit()
Jon Hallca319892017-06-15 15:25:22 -0700399
Jon Hall4173b242017-09-12 17:04:38 -0700400 def setServerOptions( self, name, ipAddress ):
401 """
402 Parse the cluster options to create an ONOS "server" component with the given name
403
404 Arguments:
405 name - The name of the server componet
406 ipAddress - The ip address of the server
407 """
408 main.componentDictionary[name] = main.componentDictionary[self.name].copy()
409 main.componentDictionary[name]['type'] = "OnosDriver"
410 main.componentDictionary[name]['host'] = ipAddress
411 home = main.componentDictionary[name]['COMPONENTS'].get( "onos_home", None )
412 main.componentDictionary[name]['home'] = self.checkOptions( home, None )
You Wang4cc61912018-08-28 10:10:58 -0700413 # TODO: for now we use karaf user name and password also for logging to the onos nodes
Jon Hall06fd0df2021-01-25 15:50:06 -0800414 # FIXME: We shouldn't use karaf* for this, what we want is another set of variables to
415 # login to a shell on the server ONOS is running on
416 #main.componentDictionary[name]['user'] = self.karafUser
417 #main.componentDictionary[name]['password'] = self.karafPass
Jon Hall4173b242017-09-12 17:04:38 -0700418 main.componentDictionary[name]['connect_order'] = str( int( main.componentDictionary[name]['connect_order'] ) + 1 )
Jon Hall4173b242017-09-12 17:04:38 -0700419
Jon Hall4173b242017-09-12 17:04:38 -0700420 def createServerComponent( self, name, ipAddress ):
421 """
422 Creates a new onos "server" component. This will be connected to the
423 node ONOS is running on.
424
425 Arguments:
426 name - The string of the name of this component. The new component
427 will be assigned to main.<name> .
428 In addition, main.<name>.name = str( name )
429 ipAddress - The ip address of the server
430 """
431 try:
432 # look to see if this component already exists
433 getattr( main, name )
434 except AttributeError:
435 # namespace is clear, creating component
436 self.setServerOptions( name, ipAddress )
437 return main.componentInit( name )
438 except pexpect.EOF:
439 main.log.error( self.name + ": EOF exception found" )
440 main.log.error( self.name + ": " + self.handle.before )
441 main.cleanAndExit()
442 except Exception:
443 main.log.exception( self.name + ": Uncaught exception!" )
444 main.cleanAndExit()
445 else:
446 # namespace is not clear!
447 main.log.error( name + " component already exists!" )
448 main.cleanAndExit()
449
Jon Hall4173b242017-09-12 17:04:38 -0700450 def createComponents( self, prefix='', createServer=True ):
Jon Hallca319892017-06-15 15:25:22 -0700451 """
452 Creates a CLI and REST component for each nodes in the cluster
453 """
454 # TODO: This needs work to support starting two seperate clusters in one test
455 cliPrefix = prefix + "cli"
456 restPrefix = prefix + "rest"
457 benchPrefix = prefix + "bench"
Jon Hall4173b242017-09-12 17:04:38 -0700458 serverPrefix = prefix + "server"
Jon Hall06fd0df2021-01-25 15:50:06 -0800459 k8sPrefix = prefix + "k8s"
Jon Hallca319892017-06-15 15:25:22 -0700460 for i in xrange( 1, self.maxNodes + 1 ):
Jeremy Ronquillo4d5f1d02017-10-13 20:23:57 +0000461 cliName = cliPrefix + str( i )
Jon Hallca319892017-06-15 15:25:22 -0700462 restName = restPrefix + str( i )
463 benchName = benchPrefix + str( i )
Jon Hall4173b242017-09-12 17:04:38 -0700464 serverName = serverPrefix + str( i )
Jon Hall06fd0df2021-01-25 15:50:06 -0800465 if self.kubeConfig:
466 k8sName = k8sPrefix + str( i )
Jon Hallca319892017-06-15 15:25:22 -0700467
468 # Unfortunately this means we need to have a cell set beofre running TestON,
469 # Even if it is just the entire possible cluster size
470 ip = self.onosIps[ 'OC' + str( i ) ]
471
Devin Lim142b5342017-07-20 15:22:39 -0700472 cli = self.createCliComponent( cliName, ip )
Jon Hallca319892017-06-15 15:25:22 -0700473 rest = self.createRestComponent( restName, ip )
474 bench = self.createBenchComponent( benchName )
Jon Hall4173b242017-09-12 17:04:38 -0700475 server = self.createServerComponent( serverName, ip ) if createServer else None
Jon Hall06fd0df2021-01-25 15:50:06 -0800476 k8s = self.createServerComponent( k8sName, ip ) if self.kubeConfig else None
477 if self.kubeConfig:
478 k8s.kubeConfig = self.kubeConfig
479 k8s.podName = None
Jon Hall3c0114c2020-08-11 15:07:42 -0700480 self.nodes.append( Controller( prefix + str( i ), ip, cli, rest, bench, i - 1,
Jon Hall06fd0df2021-01-25 15:50:06 -0800481 self.user_name, server=server, k8s=k8s,
Jon Hall3c0114c2020-08-11 15:07:42 -0700482 dockerPrompt=self.dockerPrompt ) )