Fix getting subcloud with lowest id

WIP

Change-Id: I13d2607973ecc2d6350ab5b725f62fffadff5f0c
Signed-off-by: aabhinav <ayyapasetti.abhinav@windriver.com>
This commit is contained in:
aabhinav
2025-09-17 01:43:24 -04:00
parent 61901ebe4c
commit 30df9ad676
2 changed files with 18 additions and 1 deletions

View File

@@ -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

View File

@@ -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)