wol: share the wakeonlan command via wol-sleeper/waker_command
Sleeper now exposes the full `/usr/bin/wakeonlan -i <broadcast> <mac>` invocation as wol-sleeper/waker_command; waker reads that instead of rebuilding the command line itself. Adds the `-i <subnet-broadcast>` flag so magic packets reach sleepers on a different L2 segment than the waker. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
f3122f3d0a
commit
14e055a5e0
2 changed files with 6 additions and 3 deletions
|
|
@ -45,17 +45,20 @@ defaults = {
|
|||
|
||||
@metadata_reactor.provides(
|
||||
'wol-sleeper/mac',
|
||||
'wol-sleeper/waker_command',
|
||||
'wol-sleeper/wake_command',
|
||||
)
|
||||
def wake_command(metadata):
|
||||
waker_hostname = repo.get_node(metadata.get('wol-sleeper/waker')).hostname
|
||||
mac = metadata.get(f"network/{metadata.get('wol-sleeper/network')}/mac")
|
||||
ip = ip_interface(metadata.get(f"network/{metadata.get('wol-sleeper/network')}/ipv4")).ip
|
||||
network = ip_interface(metadata.get(f"network/{metadata.get('wol-sleeper/network')}/ipv4"))
|
||||
waker_command = f"/usr/bin/wakeonlan -i {network.network.broadcast_address} {mac}"
|
||||
|
||||
return {
|
||||
'wol-sleeper': {
|
||||
'mac': mac,
|
||||
'wake_command': f"ssh -o StrictHostKeyChecking=no wol@{waker_hostname} '/usr/bin/wakeonlan {mac}' && while ! ping {ip} -c1 -W3; do true; done",
|
||||
'waker_command': waker_command,
|
||||
'wake_command': f"ssh -o StrictHostKeyChecking=no wol@{waker_hostname} '{waker_command}' && while ! ping {network.ip} -c1 -W3; do true; done",
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ def user(metadata):
|
|||
'authorized_users': {
|
||||
f'root@{ssh_client.name}': {
|
||||
'commands': {
|
||||
'/usr/bin/wakeonlan ' + sleeper.metadata.get('wol-sleeper/mac')
|
||||
sleeper.metadata.get('wol-sleeper/waker_command')
|
||||
for sleeper in repo.nodes
|
||||
if sleeper.has_bundle('wol-sleeper')
|
||||
and sleeper.metadata.get('wol-sleeper/waker') == node.name
|
||||
|
|
|
|||
Loading…
Reference in a new issue