Skip to content

Commit 2f9d5ad

Browse files
rushikeshjadhavWescoeur
authored andcommitted
Improve LinstorSR.py to handle thick SR creation (#85)
Check enabled hosts instead of online during SR creation Added `get_enabled_hosts` to get enabled hosts during SR operations. In some drivers e.g. LINSTOR, we need to ensure that hosts are enabled before performing operations, hence this function is needed. In some cases `thick` SR creation may fail due to `get_online_hosts` as the metrics could take time. Signed-off-by: Rushikesh Jadhav <[email protected]>
1 parent bdc0c70 commit 2f9d5ad

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

drivers/LinstorSR.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ def create(self, uuid, size) -> None:
586586
opterr='LINSTOR SR must be unique in a pool'
587587
)
588588

589-
online_hosts = util.get_online_hosts(self.session)
589+
online_hosts = util.get_enabled_hosts(self.session)
590590
if len(online_hosts) < len(host_adresses):
591591
raise xs_errors.XenError(
592592
'LinstorSRCreate',

drivers/util.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,11 @@ def get_slaves_attached_on(session, vdi_uuids):
778778
master_ref = get_this_host_ref(session)
779779
return [x for x in host_refs if x != master_ref]
780780

781+
def get_enabled_hosts(session):
782+
"""
783+
Returns a list of host refs that are enabled in the pool.
784+
"""
785+
return list(session.xenapi.host.get_all_records_where('field "enabled" = "true"').keys())
781786

782787
def get_online_hosts(session):
783788
online_hosts = []

0 commit comments

Comments
 (0)