From 84882e5b0bbb416ca1325e72e9185bd3f55a7b4e Mon Sep 17 00:00:00 2001 From: Rushikesh Jadhav Date: Mon, 28 Apr 2025 13:55:13 +0530 Subject: [PATCH 1/3] Added `get_enabled_hosts` to get enabled hosts during SR operations. In some drivers e.g. Linstor, we need to ensure that hosts are enabeld before performing operations, hence this function is needed. Signed-off-by: Rushikesh Jadhav --- drivers/util.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/util.py b/drivers/util.py index 4053c9a3e..bc70d1a0f 100755 --- a/drivers/util.py +++ b/drivers/util.py @@ -777,6 +777,12 @@ def get_slaves_attached_on(session, vdi_uuids): master_ref = get_this_host_ref(session) return [x for x in host_refs if x != master_ref] +def get_enabled_hosts(session): + """ + Returns a list of host refs that are enabled in the pool. + """ + enabled_hosts = list(session.xenapi.host.get_all_records_where('field "enabled" = "true"').keys()) + return enabled_hosts def get_online_hosts(session): online_hosts = [] From 2395ddbc02bd53c13a9b94a91cd625373eafa834 Mon Sep 17 00:00:00 2001 From: Rushikesh Jadhav Date: Fri, 25 Apr 2025 00:09:02 +0530 Subject: [PATCH 2/3] In some cases `thick` SR creation may fail due to `get_online_hosts` as the metrics could take time. Thus, changed the mechanism to `get_enabled_hosts`. Signed-off-by: Rushikesh Jadhav --- drivers/LinstorSR.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/LinstorSR.py b/drivers/LinstorSR.py index c2579a539..58ca5690c 100755 --- a/drivers/LinstorSR.py +++ b/drivers/LinstorSR.py @@ -586,7 +586,7 @@ def create(self, uuid, size) -> None: opterr='LINSTOR SR must be unique in a pool' ) - online_hosts = util.get_online_hosts(self.session) + online_hosts = util.get_enabled_hosts(self.session) if len(online_hosts) < len(host_adresses): raise xs_errors.XenError( 'LinstorSRCreate', From 8603033792fd3ed4c014d9a7c8d59c95c1327c0b Mon Sep 17 00:00:00 2001 From: Rushikesh Jadhav Date: Mon, 23 Jun 2025 18:26:36 +0530 Subject: [PATCH 3/3] Update drivers/util.py Avoiding extra step and variable. Co-authored-by: Ronan Abhamon Signed-off-by: Rushikesh Jadhav --- drivers/util.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/util.py b/drivers/util.py index bc70d1a0f..b663c76ab 100755 --- a/drivers/util.py +++ b/drivers/util.py @@ -781,8 +781,7 @@ def get_enabled_hosts(session): """ Returns a list of host refs that are enabled in the pool. """ - enabled_hosts = list(session.xenapi.host.get_all_records_where('field "enabled" = "true"').keys()) - return enabled_hosts + return list(session.xenapi.host.get_all_records_where('field "enabled" = "true"').keys()) def get_online_hosts(session): online_hosts = []