From e5c6ed45e98502f39bf73fc1feacc93612999377 Mon Sep 17 00:00:00 2001 From: Mahesh Shetty Date: Tue, 2 Apr 2024 11:28:43 +0530 Subject: [PATCH] review changes Signed-off-by: Mahesh Shetty --- ocs_ci/ocs/resources/cloud_manager.py | 14 +++++++++----- ocs_ci/ocs/resources/cloud_uls.py | 4 ++-- ocs_ci/utility/utils.py | 7 +++++++ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/ocs_ci/ocs/resources/cloud_manager.py b/ocs_ci/ocs/resources/cloud_manager.py index d90d33ce475b..b3a226f232ae 100644 --- a/ocs_ci/ocs/resources/cloud_manager.py +++ b/ocs_ci/ocs/resources/cloud_manager.py @@ -20,6 +20,7 @@ CommandFailed, TimeoutExpiredError, ResourceWrongStatusException, + ClusterNotInSTSModeException, ) from ocs_ci.ocs.resources.rgw import RGW from ocs_ci.utility import templating @@ -103,11 +104,14 @@ def __init__(self): setattr(self, "rgw_client", None) # set the client for STS enabled cluster - role_arn = get_role_arn_from_sub() - cred_dict["AWS"]["ROLE_ARN"] = role_arn - setattr( - self, "aws_sts_client", cloud_map["AWS_STS"](auth_dict=cred_dict["AWS"]) - ) + try: + role_arn = get_role_arn_from_sub() + cred_dict["AWS"]["ROLE_ARN"] = role_arn + setattr( + self, "aws_sts_client", cloud_map["AWS_STS"](auth_dict=cred_dict["AWS"]) + ) + except ClusterNotInSTSModeException: + setattr(self, "aws_sts_client", None) class CloudClient(ABC): diff --git a/ocs_ci/ocs/resources/cloud_uls.py b/ocs_ci/ocs/resources/cloud_uls.py index d156280121bf..83ee22f0a1c9 100644 --- a/ocs_ci/ocs/resources/cloud_uls.py +++ b/ocs_ci/ocs/resources/cloud_uls.py @@ -52,8 +52,8 @@ def cloud_uls_factory(request, cld_mgr): try: ulsMap["aws-sts"] = cld_mgr.aws_sts_client - except Exception: - log.info("Cluster is not deployed STS mode") + except AttributeError: + log.warning("Cluster is not deployed STS mode") def _create_uls(uls_dict): """ diff --git a/ocs_ci/utility/utils.py b/ocs_ci/utility/utils.py index a93aa823a7a6..d4d519c03cc1 100644 --- a/ocs_ci/utility/utils.py +++ b/ocs_ci/utility/utils.py @@ -4695,6 +4695,13 @@ def get_role_arn_from_sub(): """ Get the RoleARN from the OCS subscription + Returns: + role_arn (str): Role ARN used for ODF deployment + + Raises: + ClusterNotInSTSModeException (Exception) if cluster + not in STS mode + """ from ocs_ci.ocs.ocp import OCP