From e97d48b363b79a27e0956fb7e8e187066e4b8e86 Mon Sep 17 00:00:00 2001 From: Devaev Maxim Date: Sat, 5 Oct 2019 09:23:48 +0300 Subject: [PATCH] cdrom flag; written fix --- kvmd/apps/kvmd/server.py | 4 +++- kvmd/plugins/msd/__init__.py | 2 +- kvmd/plugins/msd/disabled.py | 5 +++-- kvmd/plugins/msd/otg.py | 5 +++-- kvmd/plugins/msd/relay.py | 3 ++- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/kvmd/apps/kvmd/server.py b/kvmd/apps/kvmd/server.py index 81f2c0b4..04030545 100644 --- a/kvmd/apps/kvmd/server.py +++ b/kvmd/apps/kvmd/server.py @@ -481,7 +481,9 @@ class Server: # pylint: disable=too-many-instance-attributes @_exposed("POST", "/msd/select") async def __msd_select_handler(self, request: aiohttp.web.Request) -> aiohttp.web.Response: - return _json(await self.__msd.select(valid_msd_image_name(request.query.get("image_name")))) + image_name = valid_msd_image_name(request.query.get("image_name")) + cdrom = valid_bool(request.query.get("cdrom", "true")) + return _json(await self.__msd.select(image_name, cdrom)) @_exposed("POST", "/msd/remove") async def __msd_remove_handler(self, request: aiohttp.web.Request) -> aiohttp.web.Response: diff --git a/kvmd/plugins/msd/__init__.py b/kvmd/plugins/msd/__init__.py index bff60232..dc6fbd51 100644 --- a/kvmd/plugins/msd/__init__.py +++ b/kvmd/plugins/msd/__init__.py @@ -92,7 +92,7 @@ class BaseMsd(BasePlugin): async def disconnect(self) -> Dict: raise NotImplementedError - async def select(self, name: str) -> Dict: + async def select(self, name: str, cdrom: bool) -> Dict: raise NotImplementedError async def remove(self, name: str) -> Dict: diff --git a/kvmd/plugins/msd/disabled.py b/kvmd/plugins/msd/disabled.py index 5eb3083b..eafbdd65 100644 --- a/kvmd/plugins/msd/disabled.py +++ b/kvmd/plugins/msd/disabled.py @@ -46,9 +46,10 @@ class Plugin(BaseMsd): "online": False, "busy": False, "uploading": False, - "written": False, + "written": 0, "current": None, "storage": None, + "cdrom": None, "connected": False, } @@ -68,7 +69,7 @@ class Plugin(BaseMsd): async def disconnect(self) -> Dict: raise MsdDisabledError() - async def select(self, name: str) -> Dict: + async def select(self, name: str, cdrom: bool) -> Dict: raise MsdDisabledError() async def remove(self, name: str) -> Dict: diff --git a/kvmd/plugins/msd/otg.py b/kvmd/plugins/msd/otg.py index 70bb3f05..db1c2254 100644 --- a/kvmd/plugins/msd/otg.py +++ b/kvmd/plugins/msd/otg.py @@ -46,9 +46,10 @@ class Plugin(BaseMsd): "online": False, "busy": False, "uploading": False, - "written": False, + "written": 0, "current": None, "storage": None, + "cdrom": None, "connected": False, } @@ -68,7 +69,7 @@ class Plugin(BaseMsd): async def disconnect(self) -> Dict: raise MsdCliOnlyError() - async def select(self, name: str) -> Dict: + async def select(self, name: str, cdrom: bool) -> Dict: raise MsdCliOnlyError() async def remove(self, name: str) -> Dict: diff --git a/kvmd/plugins/msd/relay.py b/kvmd/plugins/msd/relay.py index d53e0720..926d6526 100644 --- a/kvmd/plugins/msd/relay.py +++ b/kvmd/plugins/msd/relay.py @@ -228,6 +228,7 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes "written": self.__written, "current": current, "storage": storage, + "cdrom": None, "connected": (not self.__on_kvm), } @@ -317,7 +318,7 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes await self.__state_queue.put(state or self.get_state()) @_msd_working - async def select(self, name: str) -> Dict: + async def select(self, name: str, cdrom: bool) -> Dict: raise MsdMultiNotSupported() @_msd_working