@@ -246,13 +246,11 @@ def scale(config, plandir, cluster, overrides):
246
246
os .mkdir (clusterdir )
247
247
data ['assisted' ] = True
248
248
old_extra_nodepools = []
249
- old_assisted_vms_number = 2
250
249
if storedparameters and os .path .exists (f"{ clusterdir } /kcli_parameters.yml" ):
251
250
with open (f"{ clusterdir } /kcli_parameters.yml" , 'r' ) as install :
252
251
installparam = safe_load (install )
253
252
data .update (installparam )
254
253
plan = installparam .get ('plan' , plan )
255
- old_assisted_vms_number = installparam .get ('assisted_vms_number' , old_assisted_vms_number )
256
254
old_extra_nodepools = installparam .get ('extra_nodepools' , old_extra_nodepools )
257
255
data .update (overrides )
258
256
namespace = data ['namespace' ]
@@ -272,7 +270,6 @@ def scale(config, plandir, cluster, overrides):
272
270
warning ("KUBECONFIG not set...Using .kube/config instead" )
273
271
platform = data .get ('platform' )
274
272
assisted = platform == 'assisted'
275
- assisted_vms = data .get ('assisted_vms' )
276
273
kubevirt = platform == 'kubevirt'
277
274
with open (f"{ clusterdir } /kcli_parameters.yml" , 'w' ) as paramfile :
278
275
safe_dump (data , paramfile , default_flow_style = False , encoding = 'utf-8' , allow_unicode = True )
@@ -286,30 +283,26 @@ def scale(config, plandir, cluster, overrides):
286
283
os .chdir (os .path .expanduser ("~/.kcli" ))
287
284
old_baremetal_hosts = installparam .get ('baremetal_hosts' , [])
288
285
new_baremetal_hosts = overrides .get ('baremetal_hosts' , [])
289
- assisted_vms_number = overrides .get ('workers' ) or data ['assisted_vms_number' ]
290
- if assisted_vms and assisted_vms_number != old_assisted_vms_number :
291
- if assisted_vms_number < old_assisted_vms_number :
292
- msg = "New assisted_vms_number should be greater than old one"
293
- return {'result' : 'failure' , 'reason' : msg }
294
- if data .get ('disk_size' , 30 ) < 200 :
295
- data ['disk_size' ] = 200
296
- if data .get ('numcpus' , 8 ) < 16 :
297
- data ['numcpus' ] = 16
298
- if data .get ('memory' , 16384 ) < 20480 :
299
- data ['memory' ] = 20480
300
- worker_threaded = data .get ('threaded' , False ) or data .get ('assisted_vms_threaded' , False )
301
- result = config .plan (plan , inputfile = f'{ plandir } /kcli_plan_assisted.yml' , overrides = data ,
302
- threaded = worker_threaded )
303
- if result ['result' ] != 'success' :
304
- return result
305
- vms = result ['newvms' ]
306
- ksushy_ip = data ['assisted_vms_ksushy_ip' ]
307
- ksushy_url = f'http://{ ksushy_ip } :9000/redfish/v1/Systems/{ config .client } '
308
- virtual_hosts = []
309
- for vm in vms :
310
- new_mac = config .k .info (vm )['nets' ][0 ]['mac' ]
311
- virtual_hosts .append ({'url' : f'{ ksushy_url } /{ vm } ' , 'mac' : new_mac })
312
- new_baremetal_hosts .extend (virtual_hosts )
286
+ if assisted :
287
+ assisted_vms_number = workers - len (old_baremetal_hosts + new_baremetal_hosts )
288
+ if assisted_vms_number > 0 :
289
+ data ['assisted_vms_number ' ] = assisted_vms_number
290
+ data ['disk_size' ] = max (data ['disk_size' ], 200 )
291
+ data ['numcpus' ] = max (data ['numcpus' ], 16 )
292
+ data ['memory' ] = max (data ['memory' ], 20480 )
293
+ worker_threaded = data .get ('threaded' , False ) or data .get ('assisted_vms_threaded' , False )
294
+ result = config .plan (plan , inputfile = f'{ plandir } /kcli_plan_assisted.yml' , overrides = data ,
295
+ threaded = worker_threaded )
296
+ if result ['result' ] != 'success' :
297
+ return result
298
+ vms = result ['newvms' ]
299
+ ksushy_ip = data ['assisted_vms_ksushy_ip' ]
300
+ ksushy_url = f'http://{ ksushy_ip } :9000/redfish/v1/Systems/{ config .client } '
301
+ virtual_hosts = []
302
+ for vm in vms :
303
+ new_mac = config .k .info (vm )['nets' ][0 ]['mac' ]
304
+ virtual_hosts .append ({'url' : f'{ ksushy_url } /{ vm } ' , 'mac' : new_mac })
305
+ new_baremetal_hosts .extend (virtual_hosts )
313
306
baremetal_hosts = [entry for entry in new_baremetal_hosts if entry not in old_baremetal_hosts ]
314
307
if baremetal_hosts :
315
308
if assisted :
@@ -369,7 +362,6 @@ def create(config, plandir, cluster, overrides):
369
362
platform = data .get ('platform' )
370
363
assisted = platform == 'assisted'
371
364
data ['assisted' ] = assisted
372
- assisted_vms = data .get ('assisted_vms' )
373
365
kubevirt = platform == 'kubevirt'
374
366
data ['kubevirt' ] = kubevirt
375
367
if platform not in [None , 'kubevirt' , 'assisted' ]:
@@ -783,14 +775,13 @@ def create(config, plandir, cluster, overrides):
783
775
pprint (f"Using installer version { INSTALLER_VERSION } " )
784
776
nodepool_image = os .popen ("openshift-install version | grep 'release image' | cut -f3 -d' '" ).read ().strip ()
785
777
if assisted :
786
- if assisted_vms :
787
- if data ['disk_size' ] < 200 :
788
- data ['disk_size' ] = 200
789
- if data ['numcpus' ] < 16 :
790
- data ['numcpus' ] = 16
791
- if data ['memory' ] < 20480 :
792
- data ['memory' ] = 20480
793
- worker_threaded = data .get ('threaded' , False ) or data .get ('assisted_vms_threaded' , False )
778
+ data ['disk_size' ] = max (data ['disk_size' ], 200 )
779
+ data ['numcpus' ] = max (data ['numcpus' ], 16 )
780
+ data ['memory' ] = max (data ['memory' ], 20480 )
781
+ worker_threaded = data .get ('threaded' , False )
782
+ assisted_vms_number = workers - len (baremetal_hosts )
783
+ if assisted_vms_number > 0 :
784
+ data ['assisted_vms_number ' ] = assisted_vms_number
794
785
result = config .plan (plan , inputfile = f'{ plandir } /kcli_plan_assisted.yml' , overrides = data ,
795
786
threaded = worker_threaded )
796
787
if result ['result' ] != 'success' :
@@ -803,7 +794,6 @@ def create(config, plandir, cluster, overrides):
803
794
new_mac = config .k .info (vm )['nets' ][0 ]['mac' ]
804
795
virtual_hosts .append ({'url' : f'{ ksushy_url } /{ vm } ' , 'mac' : new_mac })
805
796
baremetal_hosts .extend (virtual_hosts )
806
- data ['assisted_vms_number' ] = len (virtual_hosts )
807
797
create_bmh_objects (config , plandir , cluster , namespace , baremetal_hosts , overrides )
808
798
agents = len (baremetal_hosts ) or 2
809
799
pprint (f"Waiting for { agents } agents to appear" )
@@ -866,7 +856,6 @@ def create(config, plandir, cluster, overrides):
866
856
installparam ['original_domain' ] = data ['original_domain' ]
867
857
if baremetal_hosts :
868
858
installparam ['baremetal_hosts' ] = baremetal_hosts
869
- installparam ['assisted_vms_number' ] = data ['assisted_vms_number' ]
870
859
installparam ['registry' ] = data .get ('registry' , 'quay.io' )
871
860
installparam ['extra_nodepools' ] = extra_nodepools
872
861
safe_dump (installparam , p , default_flow_style = False , encoding = 'utf-8' , allow_unicode = True )
0 commit comments