mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 09:10:30 +08:00
basic msd rw api
This commit is contained in:
parent
06bf0fcd17
commit
2eef9bd263
@ -70,6 +70,7 @@ class MsdApi:
|
||||
for (param, key, validator) in [
|
||||
("image", "name", (lambda arg: str(arg).strip() and valid_msd_image_name(arg))),
|
||||
("cdrom", "cdrom", valid_bool),
|
||||
("rw", "rw", valid_bool),
|
||||
]
|
||||
if request.query.get(param) is not None
|
||||
}
|
||||
|
||||
@ -93,7 +93,12 @@ class MsdMultiNotSupported(MsdOperationError):
|
||||
|
||||
class MsdCdromNotSupported(MsdOperationError):
|
||||
def __init__(self) -> None:
|
||||
super().__init__("This MSD does not support CD-ROM emulation")
|
||||
super().__init__("This MSD does not support CD-ROM switching")
|
||||
|
||||
|
||||
class MsdRwNotSupported(MsdOperationError):
|
||||
def __init__(self) -> None:
|
||||
super().__init__("This MSD does not support RW switching")
|
||||
|
||||
|
||||
# =====
|
||||
@ -114,7 +119,13 @@ class BaseMsd(BasePlugin):
|
||||
|
||||
# =====
|
||||
|
||||
async def set_params(self, name: Optional[str]=None, cdrom: Optional[bool]=None) -> None:
|
||||
async def set_params(
|
||||
self,
|
||||
name: Optional[str]=None,
|
||||
cdrom: Optional[bool]=None,
|
||||
rw: Optional[bool]=None,
|
||||
) -> None:
|
||||
|
||||
raise NotImplementedError()
|
||||
|
||||
async def set_connected(self, connected: bool) -> None:
|
||||
|
||||
@ -50,6 +50,7 @@ class Plugin(BaseMsd):
|
||||
"features": {
|
||||
"multi": False,
|
||||
"cdrom": False,
|
||||
"rw": False,
|
||||
},
|
||||
}
|
||||
|
||||
@ -63,7 +64,13 @@ class Plugin(BaseMsd):
|
||||
|
||||
# =====
|
||||
|
||||
async def set_params(self, name: Optional[str]=None, cdrom: Optional[bool]=None) -> None:
|
||||
async def set_params(
|
||||
self,
|
||||
name: Optional[str]=None,
|
||||
cdrom: Optional[bool]=None,
|
||||
rw: Optional[bool]=None,
|
||||
) -> None:
|
||||
|
||||
raise MsdDisabledError()
|
||||
|
||||
async def set_connected(self, connected: bool) -> None:
|
||||
|
||||
@ -56,6 +56,7 @@ from .. import MsdDisconnectedError
|
||||
from .. import MsdImageNotSelected
|
||||
from .. import MsdUnknownImageError
|
||||
from .. import MsdImageExistsError
|
||||
from .. import MsdRwNotSupported
|
||||
from .. import BaseMsd
|
||||
from .. import MsdImageWriter
|
||||
|
||||
@ -222,6 +223,7 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
|
||||
"features": {
|
||||
"multi": True,
|
||||
"cdrom": True,
|
||||
"rw": False,
|
||||
},
|
||||
}
|
||||
|
||||
@ -254,8 +256,17 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
|
||||
# =====
|
||||
|
||||
@aiotools.atomic
|
||||
async def set_params(self, name: Optional[str]=None, cdrom: Optional[bool]=None) -> None:
|
||||
async def set_params(
|
||||
self,
|
||||
name: Optional[str]=None,
|
||||
cdrom: Optional[bool]=None,
|
||||
rw: Optional[bool]=None,
|
||||
) -> None:
|
||||
|
||||
async with self.__state.busy():
|
||||
if rw is not None:
|
||||
raise MsdRwNotSupported()
|
||||
|
||||
assert self.__state.storage
|
||||
assert self.__state.vd
|
||||
|
||||
|
||||
@ -49,6 +49,7 @@ from .. import MsdConnectedError
|
||||
from .. import MsdDisconnectedError
|
||||
from .. import MsdMultiNotSupported
|
||||
from .. import MsdCdromNotSupported
|
||||
from .. import MsdRwNotSupported
|
||||
from .. import BaseMsd
|
||||
from .. import MsdImageWriter
|
||||
|
||||
@ -141,6 +142,7 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
|
||||
"features": {
|
||||
"multi": False,
|
||||
"cdrom": False,
|
||||
"rw": False,
|
||||
},
|
||||
}
|
||||
|
||||
@ -178,12 +180,20 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
|
||||
# =====
|
||||
|
||||
@aiotools.atomic
|
||||
async def set_params(self, name: Optional[str]=None, cdrom: Optional[bool]=None) -> None:
|
||||
async def set_params(
|
||||
self,
|
||||
name: Optional[str]=None,
|
||||
cdrom: Optional[bool]=None,
|
||||
rw: Optional[bool]=None,
|
||||
) -> None:
|
||||
|
||||
async with self.__working():
|
||||
if name is not None:
|
||||
raise MsdMultiNotSupported()
|
||||
if cdrom is not None:
|
||||
raise MsdCdromNotSupported()
|
||||
if rw is not None:
|
||||
raise MsdRwNotSupported()
|
||||
|
||||
@aiotools.atomic
|
||||
async def set_connected(self, connected: bool) -> None:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user