[pve-devel] applied: [PATCH v2 pve-manager] pvenode: Return MAC address used for WoL call on success

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Jan 22 12:20:05 CET 2019


On 1/22/19 11:49 AM, Christian Ebner wrote:
> Use the new format to verify the MAC addresses.
> The wakeonlan API call now returns the MAC address of the node to wake on
> successful sending of the WoL packet.
> pvenode finally displays this MAC address to the user as feedback.
> 
> Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
> ---
> 
> Version 2:
>     * Changed the MAC address verification to the new mac-addr format
> 

applied thanks. Followed up with a short description for the return schema definition,
and respective version bump for libpve-common-perl.

>  PVE/API2/Nodes.pm  | 7 +++++--
>  PVE/CLI/pvenode.pm | 6 +++++-
>  PVE/NodeConfig.pm  | 2 +-
>  3 files changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
> index a82d52a5..04d9c61a 100644
> --- a/PVE/API2/Nodes.pm
> +++ b/PVE/API2/Nodes.pm
> @@ -485,7 +485,10 @@ __PACKAGE__->register_method({
>  	    }),
>  	},
>      },
> -    returns => { type => "null" },
> +    returns => {
> +	type => 'string',
> +	format => 'mac-addr',
> +    },
>      code => sub {
>  	my ($param) = @_;
>  
> @@ -519,7 +522,7 @@ __PACKAGE__->register_method({
>  
>  	close($sock);
>  
> -	return undef;
> +	return $config->{wakeonlan};
>      }});
>  
>  __PACKAGE__->register_method({
> diff --git a/PVE/CLI/pvenode.pm b/PVE/CLI/pvenode.pm
> index b698d2a5..9b9ad6d3 100644
> --- a/PVE/CLI/pvenode.pm
> +++ b/PVE/CLI/pvenode.pm
> @@ -207,7 +207,11 @@ our $cmddef = {
>  	},
>      },
>  
> -    wakeonlan => [ 'PVE::API2::Nodes::Nodeinfo', 'wakeonlan', [ 'node' ], { } ],
> +    wakeonlan => [ 'PVE::API2::Nodes::Nodeinfo', 'wakeonlan', [ 'node' ], {}, sub {
> +	    my ($mac_addr) = @_;
> +
> +	    print "Wake on LAN packet send for '$mac_addr'\n";
> +	} ],
>  
>  };
>  
> diff --git a/PVE/NodeConfig.pm b/PVE/NodeConfig.pm
> index 13c04650..b52868e2 100644
> --- a/PVE/NodeConfig.pm
> +++ b/PVE/NodeConfig.pm
> @@ -64,7 +64,7 @@ my $confdesc = {
>      wakeonlan => {
>  	type => 'string',
>  	description => 'MAC address for wake on LAN',
> -	pattern => '^([0-9a-fA-F]{2}:){5}([0-9a-fA-F]{2})$',
> +	format => 'mac-addr',
>  	optional => 1,
>      },
>  };
> 





More information about the pve-devel mailing list