Skip to content

Commit

Permalink
fix(LargeBlock): Remove pathlib for python2 support
Browse files Browse the repository at this point in the history
Signed-off-by: Damien Thenot <[email protected]>
  • Loading branch information
Nambrok committed Feb 27, 2024
1 parent c0cef0c commit 7fc163c
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions drivers/LargeBlockSR.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import util
import xs_errors
import os
import pathlib

CAPABILITIES = ["SR_PROBE", "SR_UPDATE", "SR_SUPPORTS_LOCAL_CACHING",
"VDI_CREATE", "VDI_DELETE", "VDI_ATTACH", "VDI_DETACH",
Expand Down Expand Up @@ -71,17 +70,15 @@ def create(self, sr_uuid, size):
def create_loopdev(self, dev, new_path):
cmd = ["losetup", "-f", "-v", "--show", "--sector-size", str(self.LOOP_SECTOR_SIZE), dev]
self.loopdev = util.pread2(cmd).rstrip()
new_path = pathlib.Path(new_path)

try:
os.symlink(self.loopdev, new_path)
except FileExistsError as e:
raise xs_errors.XenError("SymlinkExist", opterr="Symlink {} couldn't be created".format(new_path))

def delete_loopdev(self, dev, new_path):
new_path = pathlib.Path(new_path)
if new_path.exists() and new_path.is_symlink():
new_path.unlink()
if os.path.exists(new_path) and os.path.islink(new_path):
os.unlink(new_path)

# The backing file isn't a symlink if given by ID in device-config but the real device
dev = os.path.realpath(dev)
Expand Down

0 comments on commit 7fc163c

Please sign in to comment.