Skip to content

Commit 30e76c7

Browse files
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 <[email protected]>
1 parent 120c99c commit 30e76c7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/util.py

+10
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,16 @@ def get_slaves_attached_on(session, vdi_uuids):
772772
master_ref = get_this_host_ref(session)
773773
return [x for x in host_refs if x != master_ref]
774774

775+
def get_enabled_hosts(session):
776+
"""
777+
Returns a list of host refs that are enabled in the pool.
778+
"""
779+
enabled_hosts = []
780+
hosts = session.xenapi.host.get_all_records()
781+
for host_ref, host_rec in hosts.items():
782+
if host_rec.get("enabled", True):
783+
enabled_hosts.append(host_ref)
784+
return enabled_hosts
775785

776786
def get_online_hosts(session):
777787
online_hosts = []

0 commit comments

Comments
 (0)