Wake up computers having any of the given mac addresses.
Wake on lan must be enabled on the host device. Leverages the PyPy package wakeonlan.
Parameters: |
-
mac
(str )
–
One or more mac addresses of machines to wake. Acceptable formats
are: 'AA:BB:CC:DD:EE:FF' or 'AA-BB-CC-DD-EE-FF' or 'AABBCCDDEEFF' or 'AABBCC.DDEEFF'.
|
Keyword Args:
ip: the ip address of the host to send the magic packet to.
port: the port of the host to send the magic packet to.
interface: the ip address of the network adapter to route the magic packet through.
Returns: |
-
status ( str
) –
"success" if the magic packet was sent successfully; "failure" otherwise.
|
Source code in wolproxypycli/main.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49 | @wolproxy_cli.command()
def wol(
mac: str,
ip: str = wakeonlan.BROADCAST_IP,
port: int = wakeonlan.DEFAULT_PORT,
interface: Optional[str] = None,
) -> str:
"""Wake up computers having any of the given mac addresses.
Wake on lan must be enabled on the host device. Leverages the PyPy package wakeonlan.
Args:
mac: One or more mac addresses of machines to wake. Acceptable formats
are: 'AA:BB:CC:DD:EE:FF' or 'AA-BB-CC-DD-EE-FF' or 'AABBCCDDEEFF' or 'AABBCC.DDEEFF'.
Keyword Args:
ip: the ip address of the host to send the magic packet to.
port: the port of the host to send the magic packet to.
interface: the ip address of the network adapter to route the magic packet through.
Returns:
status: "success" if the magic packet was sent successfully; "failure" otherwise.
"""
logger.info("Sending WOL magic packet to address %s", mac)
if ip is None or ip == "":
ip = "255.255.255.255"
if port is None or port <= 0 or port > 65535:
port = 9
try:
wakeonlan.send_magic_packet(*(mac,), ip_address=ip, port=port, interface=interface)
status = STATUS_OK
except Exception as ex:
logger.error(ex)
status = STATUS_FAIL
return status
|