From 30df9ad676bfa2709b700684b24e4ebef73f52d1 Mon Sep 17 00:00:00 2001 From: aabhinav Date: Wed, 17 Sep 2025 01:43:24 -0400 Subject: [PATCH] Fix getting subcloud with lowest id WIP Change-Id: I13d2607973ecc2d6350ab5b725f62fffadff5f0c Signed-off-by: aabhinav --- .../objects/dcmanager_subcloud_list_output.py | 17 +++++++++++++++++ .../test_subcloud_phased_deployment.py | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/keywords/cloud_platform/dcmanager/objects/dcmanager_subcloud_list_output.py b/keywords/cloud_platform/dcmanager/objects/dcmanager_subcloud_list_output.py index 60062e56..47d23e62 100644 --- a/keywords/cloud_platform/dcmanager/objects/dcmanager_subcloud_list_output.py +++ b/keywords/cloud_platform/dcmanager/objects/dcmanager_subcloud_list_output.py @@ -302,3 +302,20 @@ class DcManagerSubcloudListOutput: get_logger().log_exception(error_message) raise ValueError(error_message) return max(subclouds_by_type, key=lambda subcloud: int(subcloud.get_id())) + + def get_subcloud_with_lowest_id(self) -> DcManagerSubcloudListObject: + """Gets an instance of DcManagerSubcloudListObject with the lowest ID regardless of its state. + + Returns: + DcManagerSubcloudListObject: the instance of DcManagerSubcloudListObject with the lowest ID. + + """ + subclouds = self.get_dcmanager_subcloud_list_objects_filtered(None) + + if not subclouds: + error_message = "In this DC system, there are no subclouds." + get_logger().log_exception(error_message) + raise ValueError(error_message) + + lowest_subcloud = min(subclouds, key=lambda subcloud: int(subcloud.get_id())) + return lowest_subcloud diff --git a/testcases/cloud_platform/regression/dc/phased_deployment/test_subcloud_phased_deployment.py b/testcases/cloud_platform/regression/dc/phased_deployment/test_subcloud_phased_deployment.py index ba97fe7d..f75c36ec 100644 --- a/testcases/cloud_platform/regression/dc/phased_deployment/test_subcloud_phased_deployment.py +++ b/testcases/cloud_platform/regression/dc/phased_deployment/test_subcloud_phased_deployment.py @@ -36,7 +36,7 @@ def get_undeployed_subcloud_name(ssh_connection: SSHConnection) -> str: get_logger().log_info("No Undeployed Subcloud found deleting existing one") # Gets the lowest subcloud (the subcloud with the lowest id). get_logger().log_info("Obtaining subcloud with the lowest ID.") - lowest_subcloud = dcm_sc_list_kw.get_dcmanager_subcloud_list().get_healthy_subcloud_with_lowest_id() + lowest_subcloud = dcm_sc_list_kw.get_dcmanager_subcloud_list().get_subcloud_with_lowest_id() get_logger().log_info(f"Subcloud with the lowest ID obtained: ID={lowest_subcloud.get_id()}, Name={lowest_subcloud.get_name()}, Management state={lowest_subcloud.get_management()}") subcloud_name = lowest_subcloud.get_name() dcm_sc_manager_kw = DcManagerSubcloudManagerKeywords(ssh_connection)