summaryrefslogtreecommitdiff
path: root/kvmd/plugins/msd/otg
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2022-04-10 06:00:10 +0300
committerMaxim Devaev <[email protected]>2022-04-10 06:00:10 +0300
commit486f1be9867fcb3220a2918ddd5b0371ece17d5d (patch)
tree22f6297f9a4755631c0aee3397980a8e2dde0d22 /kvmd/plugins/msd/otg
parent122242ea472684434989706253bb38ad48a6cbd6 (diff)
get rid of the otg-unlock helper
Diffstat (limited to 'kvmd/plugins/msd/otg')
-rw-r--r--kvmd/plugins/msd/otg/__init__.py11
-rw-r--r--kvmd/plugins/msd/otg/drive.py5
-rw-r--r--kvmd/plugins/msd/otg/helpers.py10
3 files changed, 4 insertions, 22 deletions
diff --git a/kvmd/plugins/msd/otg/__init__.py b/kvmd/plugins/msd/otg/__init__.py
index 38a09d84..dcf70557 100644
--- a/kvmd/plugins/msd/otg/__init__.py
+++ b/kvmd/plugins/msd/otg/__init__.py
@@ -140,7 +140,6 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
storage_path: str,
remount_cmd: List[str],
- unlock_cmd: List[str],
initial: Dict,
@@ -155,7 +154,6 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
self.__meta_path = os.path.join(self.__storage_path, "meta")
self.__remount_cmd = remount_cmd
- self.__unlock_cmd = unlock_cmd
self.__initial_image: str = initial["image"]
self.__initial_cdrom: bool = initial["cdrom"]
@@ -182,7 +180,6 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
"storage": Option("/var/lib/kvmd/msd", type=valid_abs_dir, unpack_as="storage_path"),
"remount_cmd": Option([*sudo, "/usr/bin/kvmd-helper-otgmsd-remount", "{mode}"], type=valid_command),
- "unlock_cmd": Option([*sudo, "/usr/bin/kvmd-helper-otgmsd-unlock", "unlock"], type=valid_command),
"initial": {
"image": Option("", type=valid_printable_filename, if_empty=""),
@@ -242,7 +239,6 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
async def reset(self) -> None:
async with self.__state.busy(check_online=False):
try:
- await self.__unlock_drive()
self.__drive.set_image_path("")
self.__drive.set_rw_flag(False)
self.__drive.set_cdrom_flag(False)
@@ -292,15 +288,12 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
if not os.path.exists(self.__state.vd.image.path):
raise MsdUnknownImageError()
- await self.__unlock_drive()
self.__drive.set_cdrom_flag(self.__state.vd.cdrom)
self.__drive.set_image_path(self.__state.vd.image.path)
else:
if not (self.__state.vd.connected or self.__drive.get_image_path()):
raise MsdDisconnectedError()
-
- await self.__unlock_drive()
self.__drive.set_image_path("")
self.__state.vd.connected = connected
@@ -479,7 +472,6 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
if os.path.exists(path):
logger.info("Setting up initial image %r ...", self.__initial_image)
try:
- await self.__unlock_drive()
self.__drive.set_cdrom_flag(self.__initial_cdrom)
self.__drive.set_image_path(path)
except Exception:
@@ -547,6 +539,3 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
async def __remount_storage(self, rw: bool) -> None:
await helpers.remount_storage(self.__remount_cmd, rw)
-
- async def __unlock_drive(self) -> None:
- await helpers.unlock_drive(self.__unlock_cmd)
diff --git a/kvmd/plugins/msd/otg/drive.py b/kvmd/plugins/msd/otg/drive.py
index ee54e5e9..11af7f81 100644
--- a/kvmd/plugins/msd/otg/drive.py
+++ b/kvmd/plugins/msd/otg/drive.py
@@ -53,7 +53,10 @@ class Drive:
# =====
def set_image_path(self, path: str) -> None:
- self.__set_param("file", path)
+ if path:
+ self.__set_param("file", path)
+ else:
+ self.__set_param("forced_eject", "")
def get_image_path(self) -> str:
return self.__get_param("file")
diff --git a/kvmd/plugins/msd/otg/helpers.py b/kvmd/plugins/msd/otg/helpers.py
index 19cb0bbb..2d64bd0c 100644
--- a/kvmd/plugins/msd/otg/helpers.py
+++ b/kvmd/plugins/msd/otg/helpers.py
@@ -45,16 +45,6 @@ async def remount_storage(base_cmd: List[str], rw: bool) -> None:
raise
-async def unlock_drive(base_cmd: List[str]) -> None:
- logger = get_logger(0)
- logger.info("Unlocking the drive ...")
- try:
- await _run_helper(base_cmd)
- except Exception:
- logger.error("Can't unlock the drive")
- raise
-
-
# =====
async def _run_helper(cmd: List[str]) -> None:
logger = get_logger(0)