Skip to content

Commit fb254f1

Browse files
committed
Migrate blktap2.py to now APISession, remove call to XAPI.getSession in cleanup.py
Due to the rebase, some old-style session management appeared, this commit makes them use the new APISession. Signed-off-by: Arnaud Garcia-Fernandez <arnaud.garcia-fernandez@vates.tech>
1 parent 95a0211 commit fb254f1

2 files changed

Lines changed: 9 additions & 12 deletions

File tree

drivers/blktap2.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,8 @@ def abort_linstor_gc(drbd_path: str) -> bool:
882882

883883
openers = get_all_volume_openers(volume_name, "0")
884884

885-
session = util.timeout(5, util.get_localAPI_session)
885+
api_session = util.timeout(5, util.APISession, "blktap-abort_linstor_gc")
886+
session = api_session.session
886887
try:
887888
srs = util.get_linstor_srs_uuid(session)
888889
pbd_ref = util.find_pbd_ref_from_dconf_value(
@@ -902,7 +903,7 @@ def abort_linstor_gc(drbd_path: str) -> bool:
902903

903904
util.SMlog(f"Unable to run tapdisk, openers of DRBD resource `{drbd_path}`: {openers}")
904905
finally:
905-
session.xenapi.session.logout()
906+
api_session.logout()
906907

907908
return False
908909

drivers/cleanup.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3928,16 +3928,12 @@ def _abort_gc_from_openers(uuid: str, is_vdi_uuid: bool, openers: "LinstorVolume
39283928
if node_name == hostname:
39293929
continue
39303930

3931-
with util.timeout(5):
3932-
session = XAPI.getSession()
3933-
try:
3934-
sr_uuid = util.get_sr_uuid_from_vdi_uuid(session, uuid) if is_vdi_uuid else uuid
3935-
util.SMlog(f"LINSTOR volume is coalescing on `{sr_uuid}`. We're going to interrupt the GC...")
3936-
return util.strtobool(session.xenapi.host.call_plugin(
3937-
util.get_master_ref(session), MANAGER_PLUGIN, "abortGc", {"srUuid": sr_uuid}
3938-
))
3939-
finally:
3940-
session.xenapi.session.logout()
3931+
with util.timeout(5), util.APISession("GC-coalescing") as session:
3932+
sr_uuid = util.get_sr_uuid_from_vdi_uuid(session, uuid) if is_vdi_uuid else uuid
3933+
util.SMlog(f"LINSTOR volume is coalescing on `{sr_uuid}`. We're going to interrupt the GC...")
3934+
return util.strtobool(session.xenapi.host.call_plugin(
3935+
util.get_master_ref(session), MANAGER_PLUGIN, "abortGc", {"srUuid": sr_uuid}
3936+
))
39413937
return False
39423938

39433939

0 commit comments

Comments
 (0)