-
Notifications
You must be signed in to change notification settings - Fork 23.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
win_wakeonlan: New module to send Wake-On-Lan packets #26232
Conversation
|
||
# Broadcast payload to network | ||
$UDPclient = new-Object System.Net.Sockets.UdpClient | ||
$UDPclient.Connect($broadcast, $port) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider passing $check_mode to Wake-On-Lan function and only wrapping L55-56 in 'if (-not $check_mode) to ensure the mac format validation happens even in check mode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely, that's good feedback.
I mostly translated it from my python version, and I am not doing that there. So I am going to backport this there too. Plus integration test (not testing if it actually works, but at least gives some coverage).
Looks good. see inline comment regarding doing as much as possible even in check mode but otherwise this looks good to go. |
6f7dbd8
to
fab7d7f
Compare
@SamLiu79 @timothyvandenbrande @ar7z1 @blakfeld @brianlloyd @chrishoffman @if-meaton @joshludwig @petemounce @schwartzmx @smadam813 As a maintainer of a module in the same namespace this new module has been submitted to, your vote counts for shipits. Please review this module and add |
shipit |
I am happy to merge this one if anyone else can review this too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shipit
looks good shipit |
|
||
# If we don't end up with 12 hexadecimal characters, fail | ||
if ($mac.Length -ne 12) { | ||
Fail-Json @{} "Incorrect MAC address length: $mac_orig" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fail-Json $result ""
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, within the function $result was not exposed, but since we don't have a function, this is no longer an issue.
$params = Parse-Args $args -supports_check_mode $true | ||
$check_mode = Get-AnsibleParam -obj $params -name "_ansible_check_mode" -type "bool" -default $false | ||
|
||
$mac = Get-AnsibleParam -obj $params -name "mac" -type "str" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be mandatory like wakeonlan
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, fixed.
changed = $true | ||
} | ||
|
||
Function Wake-On-Lan($mac, $broadcast, $port, $whatif) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the point of having this in a function, can we just make it simpler by having the code outside? Also you don't need to pass in $whatif
, you can access $check_mode
from within this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was done exactly like the python version. But there's no real point, it's even easier not to do it :-)
version_added: '2.4' | ||
short_description: Send a magic Wake-on-LAN (WoL) broadcast packet | ||
description: | ||
- The C(wakeonlan) module sends magic Wake-on-LAN (WoL) broadcast packets. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C(win_wakeonlan)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup !
default: 7 | ||
author: | ||
- Dag Wieers (@dagwieers) | ||
todo: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is todo a valid document entry?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not being exposed, which is fine. But it could be processed if needed.
Best of both worlds IMO.
This is the Windows implementation of the **wakeonlan** module. Useful if you want to wake up systems in a remote network with only Windows systems.
Thanks for all the feedback ! Looking even better now :-) |
merged, thanks @dagwieers |
SUMMARY
This is the Windows implementation of the wakeonlan module.
Useful if you want to wake up systems in a remote network with only Windows systems.
ISSUE TYPE
COMPONENT NAME
win_wakeonlan
ANSIBLE VERSION
v2.4