mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 09:10:30 +08:00
soft of by default
This commit is contained in:
parent
76bc1bcea6
commit
fb9b1b555d
@ -110,10 +110,10 @@ class IpmiServer(BaseIpmiServer): # pylint: disable=too-many-instance-attribute
|
|||||||
|
|
||||||
def __chassis_control_handler(self, request: Dict, session: IpmiServerSession) -> None:
|
def __chassis_control_handler(self, request: Dict, session: IpmiServerSession) -> None:
|
||||||
handle = {
|
handle = {
|
||||||
0: "/atx/power?action=off",
|
0: "/atx/power?action=off_hard",
|
||||||
1: "/atx/power?action=on",
|
1: "/atx/power?action=on",
|
||||||
3: "/atx/power?action=reset",
|
3: "/atx/power?action=reset_hard",
|
||||||
5: "/atx/power?action=off_soft",
|
5: "/atx/power?action=off",
|
||||||
}.get(request["data"][0], "")
|
}.get(request["data"][0], "")
|
||||||
if handle:
|
if handle:
|
||||||
if self.__make_request("POST", handle, session)[0] == 409:
|
if self.__make_request("POST", handle, session)[0] == 409:
|
||||||
|
|||||||
@ -136,20 +136,20 @@ class Atx: # pylint: disable=too-many-instance-attributes
|
|||||||
|
|
||||||
@_atx_working
|
@_atx_working
|
||||||
async def power_off(self) -> bool:
|
async def power_off(self) -> bool:
|
||||||
if self.get_state()["leds"]["power"]:
|
|
||||||
await self.click_power_long()
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
@_atx_working
|
|
||||||
async def power_off_soft(self) -> bool:
|
|
||||||
if self.get_state()["leds"]["power"]:
|
if self.get_state()["leds"]["power"]:
|
||||||
await self.click_power()
|
await self.click_power()
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@_atx_working
|
@_atx_working
|
||||||
async def power_reset(self) -> bool:
|
async def power_off_hard(self) -> bool:
|
||||||
|
if self.get_state()["leds"]["power"]:
|
||||||
|
await self.click_power_long()
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
@_atx_working
|
||||||
|
async def power_reset_hard(self) -> bool:
|
||||||
if self.get_state()["leds"]["power"]:
|
if self.get_state()["leds"]["power"]:
|
||||||
await self.click_reset()
|
await self.click_reset()
|
||||||
return True
|
return True
|
||||||
|
|||||||
@ -437,8 +437,8 @@ class Server: # pylint: disable=too-many-instance-attributes
|
|||||||
done = await ({
|
done = await ({
|
||||||
"on": self.__atx.power_on,
|
"on": self.__atx.power_on,
|
||||||
"off": self.__atx.power_off,
|
"off": self.__atx.power_off,
|
||||||
"off_soft": self.__atx.power_off_soft,
|
"off_hard": self.__atx.power_off_hard,
|
||||||
"reset": self.__atx.power_reset,
|
"reset_hard": self.__atx.power_reset_hard,
|
||||||
}[action])()
|
}[action])()
|
||||||
return _json({"action": action, "done": done})
|
return _json({"action": action, "done": done})
|
||||||
|
|
||||||
|
|||||||
@ -31,7 +31,7 @@ from .basic import valid_number
|
|||||||
|
|
||||||
# =====
|
# =====
|
||||||
def valid_atx_power_action(arg: Any) -> str:
|
def valid_atx_power_action(arg: Any) -> str:
|
||||||
return check_string_in_list(arg, "ATX power action", ["on", "off", "off_soft", "reset"])
|
return check_string_in_list(arg, "ATX power action", ["on", "off", "off_hard", "reset_hard"])
|
||||||
|
|
||||||
|
|
||||||
def valid_atx_button(arg: Any) -> str:
|
def valid_atx_button(arg: Any) -> str:
|
||||||
|
|||||||
@ -40,7 +40,7 @@ from kvmd.validators.kvm import valid_hid_mouse_wheel
|
|||||||
|
|
||||||
|
|
||||||
# =====
|
# =====
|
||||||
@pytest.mark.parametrize("arg", ["ON ", "OFF ", "OFF_soft ", "RESET "])
|
@pytest.mark.parametrize("arg", ["ON ", "OFF ", "OFF_HARD ", "RESET_HARD "])
|
||||||
def test_ok__valid_atx_power_action(arg: Any) -> None:
|
def test_ok__valid_atx_power_action(arg: Any) -> None:
|
||||||
assert valid_atx_power_action(arg) == arg.strip().lower()
|
assert valid_atx_power_action(arg) == arg.strip().lower()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user