Skip to content

Commit 97e2083

Browse files
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 0d47a41 commit 97e2083

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
@@ -777,6 +777,11 @@ def get_slaves_attached_on(session, vdi_uuids):
777777
master_ref = get_this_host_ref(session)
778778
return [x for x in host_refs if x != master_ref]
779779

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

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

0 commit comments

Comments
 (0)