Skip to content

Commit 25b62db

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 305d84f commit 25b62db

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
@@ -881,7 +881,8 @@ def abort_linstor_gc(drbd_path: str) -> bool:
881881

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

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

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

906907
return False
907908

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)