MCPcopy Index your code
hub / github.com/saltstack/salt / wol

Function wol

salt/modules/network.py:40–56  ·  view source on GitHub ↗

Send Wake On Lan packet to a host CLI Example: .. code-block:: bash salt '*' network.wol 08-00-27-13-69-77 salt '*' network.wol 080027136977 255.255.255.255 7 salt '*' network.wol 08:00:27:13:69:77 255.255.255.255 7

(mac, bcast="255.255.255.255", destport=9)

Source from the content-addressed store, hash-verified

38
39
40def wol(mac, bcast="255.255.255.255", destport=9):
41 """
42 Send Wake On Lan packet to a host
43
44 CLI Example:
45
46 .. code-block:: bash
47
48 salt '*' network.wol 08-00-27-13-69-77
49 salt '*' network.wol 080027136977 255.255.255.255 7
50 salt '*' network.wol 08:00:27:13:69:77 255.255.255.255 7
51 """
52 dest = __utils__["network.mac_str_to_bytes"](mac)
53 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
54 sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
55 sock.sendto(b"\xff" * 6 + dest * 16, (bcast, int(destport)))
56 return True
57
58
59def ping(host, timeout=False, return_boolean=False):

Callers

nothing calls this directly

Calls 3

socketMethod · 0.45
setsockoptMethod · 0.45
sendtoMethod · 0.45

Tested by

no test coverage detected