5
5
import time
6
6
from concurrent .futures import ThreadPoolExecutor
7
7
from ocs_ci .deployment .cnv import CNVInstaller
8
+ from ocs_ci .deployment .hyperconverged import HyperConverged
8
9
from ocs_ci .deployment .mce import MCEInstaller
9
10
from ocs_ci .deployment .deployment import Deployment
10
11
from ocs_ci .deployment .helpers .hypershift_base import (
22
23
CommandFailed ,
23
24
TimeoutExpiredError ,
24
25
ResourceWrongStatusException ,
26
+ UnexpectedDeploymentConfiguration ,
25
27
)
26
28
from ocs_ci .ocs .ocp import OCP
27
29
from ocs_ci .ocs .resources .catalog_source import CatalogSource
36
38
from ocs_ci .utility .utils import (
37
39
exec_cmd ,
38
40
TimeoutSampler ,
39
- get_ocp_version ,
40
- get_latest_release_version ,
41
41
)
42
42
from ocs_ci .utility .version import get_semantic_version
43
43
from ocs_ci .ocs .resources .storage_client import StorageClient
@@ -260,12 +260,50 @@ def deploy_hosted_ocp_clusters(self, cluster_names_list=None):
260
260
# operators and finish the rest preparation steps. For the rest of the clusters we will only deploy OCP
261
261
# with hcp command.
262
262
first_ocp_deployment = index == 0
263
- cluster_name = hosted_ocp_cluster .deploy_ocp (
264
- deploy_cnv = first_ocp_deployment ,
265
- deploy_acm_hub = first_ocp_deployment ,
263
+
264
+ # Put logic on checking and deploying dependencies here
265
+ if first_ocp_deployment :
266
+ # ACM installation is a default for Provider/Converged deployments
267
+ deploy_acm_hub = config .ENV_DATA .get ("deploy_acm_hub_cluster" , True )
268
+ # CNV installation is a default for Provider/Converged deployments
269
+ deploy_cnv = config .DEPLOYMENT .get ("cnv_deployment" , True )
270
+ deploy_mce = config .DEPLOYMENT .get ("mce_deployment" , False )
271
+ deploy_hyperconverged = config .ENV_DATA .get (
272
+ "deploy_hyperconverged" , False
273
+ )
274
+
275
+ # Validate conflicting deployments
276
+ if deploy_acm_hub and deploy_mce :
277
+ raise UnexpectedDeploymentConfiguration (
278
+ "Conflict: Both 'deploy_acm_hub_cluster' and 'mce_deployment' are enabled. Choose one."
279
+ )
280
+ if deploy_cnv and deploy_hyperconverged :
281
+ raise UnexpectedDeploymentConfiguration (
282
+ "Conflict: Both 'cnv_deployment' and 'deploy_hyperconverged' are enabled. Choose one."
283
+ )
284
+
285
+ else :
286
+ deploy_acm_hub = False
287
+ deploy_cnv = False
288
+ deploy_hyperconverged = False
289
+ deploy_mce = False
290
+
291
+ if not config .ENV_DATA ["platform" ].lower () in HCI_PROVIDER_CLIENT_PLATFORMS :
292
+ raise ProviderModeNotFoundException ()
293
+
294
+ if not config .ENV_DATA .get ("deploy_acm_hub_cluster" , True ):
295
+ deploy_acm_hub = False
296
+
297
+ hosted_ocp_cluster .deploy_dependencies (
298
+ deploy_acm_hub = deploy_acm_hub ,
299
+ deploy_cnv = deploy_cnv ,
266
300
deploy_metallb = first_ocp_deployment ,
267
301
download_hcp_binary = first_ocp_deployment ,
302
+ deploy_hyperconverged = deploy_hyperconverged ,
303
+ deploy_mce = deploy_mce ,
268
304
)
305
+
306
+ cluster_name = hosted_ocp_cluster .deploy_ocp ()
269
307
if cluster_name :
270
308
cluster_names .append (cluster_name )
271
309
@@ -361,14 +399,20 @@ def deploy_multiple_odf_clients(self):
361
399
362
400
363
401
class HypershiftHostedOCP (
364
- HyperShiftBase , MetalLBInstaller , CNVInstaller , Deployment , MCEInstaller
402
+ HyperShiftBase ,
403
+ MetalLBInstaller ,
404
+ CNVInstaller ,
405
+ Deployment ,
406
+ MCEInstaller ,
407
+ HyperConverged ,
365
408
):
366
409
def __init__ (self , name ):
367
410
Deployment .__init__ (self )
368
411
HyperShiftBase .__init__ (self )
369
412
MetalLBInstaller .__init__ (self )
370
413
CNVInstaller .__init__ (self )
371
414
MCEInstaller .__init__ (self )
415
+ HyperConverged .__init__ (self )
372
416
self .name = name
373
417
if config .ENV_DATA .get ("clusters" , {}).get (self .name ):
374
418
cluster_path = (
@@ -384,36 +428,16 @@ def __init__(self, name):
384
428
f"Cluster path for desired cluster with name '{ self .name } ' was not found in ENV_DATA.clusters"
385
429
)
386
430
387
- def deploy_ocp (
388
- self ,
389
- deploy_cnv = True ,
390
- deploy_acm_hub = True ,
391
- deploy_metallb = True ,
392
- download_hcp_binary = True ,
393
- deploy_mce = True ,
394
- ):
431
+ def deploy_ocp (self , ** kwargs ) -> str :
395
432
"""
396
433
Deploy hosted OCP cluster on provisioned Provider platform
397
434
398
435
Args:
399
- deploy_cnv: (bool) Deploy CNV
400
- deploy_acm_hub: (bool) Deploy ACM Hub
401
- deploy_metallb: (bool) Deploy MetalLB
402
- download_hcp_binary: (bool) Download HCP binary
436
+ **kwargs: Additional arguments for create_kubevirt_ocp_cluster (currently not in use)
403
437
404
438
Returns:
405
439
str: Name of the hosted cluster
406
440
"""
407
- if not config .ENV_DATA ["platform" ].lower () in HCI_PROVIDER_CLIENT_PLATFORMS :
408
- raise ProviderModeNotFoundException ()
409
-
410
- if not config .ENV_DATA .get ("deploy_acm_hub_cluster" , True ):
411
- deploy_acm_hub = False
412
-
413
- self .deploy_dependencies (
414
- deploy_acm_hub , deploy_cnv , deploy_metallb , download_hcp_binary , deploy_mce
415
- )
416
-
417
441
ocp_version = str (config .ENV_DATA ["clusters" ][self .name ].get ("ocp_version" ))
418
442
if ocp_version and len (ocp_version .split ("." )) == 2 :
419
443
# if ocp_version is provided in form x.y, we need to get the full form x.y.z
@@ -461,6 +485,7 @@ def deploy_dependencies(
461
485
deploy_metallb ,
462
486
download_hcp_binary ,
463
487
deploy_mce ,
488
+ deploy_hyperconverged ,
464
489
):
465
490
"""
466
491
Deploy dependencies for hosted OCP cluster
@@ -470,8 +495,17 @@ def deploy_dependencies(
470
495
deploy_metallb: bool Deploy MetalLB
471
496
download_hcp_binary: bool Download HCP binary
472
497
deploy_mce: bool Deploy mce
498
+ deploy_hyperconverged: bool Deploy Hyperconverged
473
499
474
500
"""
501
+
502
+ # log out all args in one log.info
503
+ logger .info (
504
+ f"Deploying dependencies for hosted OCP cluster '{ self .name } ': "
505
+ f"deploy_acm_hub={ deploy_acm_hub } , deploy_cnv={ deploy_cnv } , "
506
+ f"deploy_metallb={ deploy_metallb } , download_hcp_binary={ download_hcp_binary } , "
507
+ f"deploy_mce={ deploy_mce } , deploy_hyperconverged={ deploy_hyperconverged } "
508
+ )
475
509
initial_default_sc = helpers .get_default_storage_class ()
476
510
logger .info (f"Initial default StorageClass: { initial_default_sc } " )
477
511
if not initial_default_sc == constants .CEPHBLOCKPOOL_SC :
@@ -483,8 +517,15 @@ def deploy_dependencies(
483
517
except CommandFailed as e :
484
518
logger .error (f"Failed to change default StorageClass: { e } " )
485
519
486
- if deploy_cnv :
520
+ if deploy_cnv and not deploy_hyperconverged :
487
521
self .deploy_cnv (check_cnv_ready = True )
522
+ elif deploy_hyperconverged and not deploy_cnv :
523
+ self .deploy_hyperconverged ()
524
+ elif deploy_cnv and deploy_hyperconverged :
525
+ raise UnexpectedDeploymentConfiguration (
526
+ "Both deploy_cnv and deploy_hyperconverged are set to True. "
527
+ "Please choose only one of them."
528
+ )
488
529
if deploy_acm_hub :
489
530
self .deploy_acm_hub ()
490
531
if deploy_metallb :
@@ -495,30 +536,6 @@ def deploy_dependencies(
495
536
self .deploy_mce ()
496
537
self .validate_mce_deployment ()
497
538
498
- provider_ocp_version = str (
499
- get_semantic_version (get_ocp_version (), only_major_minor = True )
500
- )
501
- latest_released_ocp_version = str (
502
- get_semantic_version (get_latest_release_version (), only_major_minor = True )
503
- )
504
-
505
- if provider_ocp_version > latest_released_ocp_version :
506
- logger .info ("running on unreleased OCP version" )
507
- if config .ENV_DATA .get ("install_hypershift_upstream" ):
508
- try :
509
- self .disable_multicluster_engine ()
510
- # avoid timelapse error "
511
- # Error: [serviceaccounts "operator" is forbidden: unable to create new content"
512
- logger .info (
513
- "Sleeping for 5 minutes after disable_multicluster_engine()"
514
- )
515
- time .sleep (5 * 60 )
516
- self .install_hypershift_upstream_on_cluster ()
517
- except CommandFailed as e :
518
- raise AssertionError (
519
- f"Failed to install Hypershift on the cluster: { e } "
520
- )
521
-
522
539
# Enable central infrastructure management service for agent
523
540
if config .DEPLOYMENT .get ("hosted_cluster_platform" ) == "agent" :
524
541
provisioning_obj = OCP (** OCP (kind = constants .PROVISIONING ).get ()[0 ])
0 commit comments