On 4/8/19 3:28 PM, Christian Ebner wrote: > In order to send the WoL packet to a specific broadcast domain, the user can > define the broadcast address in the config, as fallback 255.255.255.255 is > used. > By this, the route and therefore the NIC is decided by the kernel. > > Signed-off-by: Christian Ebner <c.eb...@proxmox.com> > --- > PVE/API2/Nodes.pm | 25 ++++++++++++++++++++----- > PVE/CLI/pvenode.pm | 2 +- > PVE/NodeConfig.pm | 6 ++++++ > www/manager6/node/CmdMenu.js | 3 ++- > 4 files changed, 29 insertions(+), 7 deletions(-) > > diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm > index 8a2c2384..81596f25 100644 > --- a/PVE/API2/Nodes.pm > +++ b/PVE/API2/Nodes.pm > @@ -490,9 +490,19 @@ __PACKAGE__->register_method({ > }, > }, > returns => { > - type => 'string', > - format => 'mac-addr', > - description => 'MAC address used to assemble the WoL magic packet.', > + type => 'object', > + properties => { > + wakeonlan => { > + type => 'string', > + format => 'mac-addr', > + description => 'MAC address used to assemble the WoL magic > packet.', > + }, > + wakeonlanaddr => { > + type => 'string', > + format => 'ip', > + description => 'IP-Broadcast address used to send the WoL magic > packet.', > + }, > + }, > }, > code => sub { > my ($param) = @_; > @@ -506,6 +516,9 @@ __PACKAGE__->register_method({ > > my $config = PVE::NodeConfig::load_config($node); > my $mac_addr = $config->{wakeonlan}; > + my $broadcast_addr = $config->{wakeonlanaddr}; > + $broadcast_addr = '255.255.255.255' if !defined $broadcast_addr; > + > if (!defined($mac_addr)) { > die "No wake on LAN MAC address defined for '$node'!\n"; > } > @@ -513,7 +526,7 @@ __PACKAGE__->register_method({ > $mac_addr =~ s/://g; > my $packet = chr(0xff) x 6 . pack('H*', $mac_addr) x 16; > > - my $addr = gethostbyname('255.255.255.255'); > + my $addr = gethostbyname($broadcast_addr); > my $port = getservbyname('discard', 'udp'); > my $to = Socket::pack_sockaddr_in($port, $addr); > > @@ -527,7 +540,9 @@ __PACKAGE__->register_method({ > > close($sock); > > - return $config->{wakeonlan}; > + my $ret->{wakeonlan} = $config->{wakeonlan}; > + $ret->{wakeonlanaddr} = $broadcast_addr; > + return $ret; > }}); > > __PACKAGE__->register_method({ > diff --git a/PVE/CLI/pvenode.pm b/PVE/CLI/pvenode.pm > index 1989e8b3..41120050 100644 > --- a/PVE/CLI/pvenode.pm > +++ b/PVE/CLI/pvenode.pm > @@ -212,7 +212,7 @@ our $cmddef = { > wakeonlan => [ 'PVE::API2::Nodes::Nodeinfo', 'wakeonlan', [ 'node' ], > {}, sub { > my ($mac_addr) = @_; > > - print "Wake on LAN packet send for '$mac_addr'\n"; > + print "Wake on LAN packet send for '$mac_addr->{wakeonlan}' via > '$mac_addr->{wakeonlanaddr}'\n"; > } ], > > }; > diff --git a/PVE/NodeConfig.pm b/PVE/NodeConfig.pm > index b52868e2..4f9df886 100644 > --- a/PVE/NodeConfig.pm > +++ b/PVE/NodeConfig.pm > @@ -67,6 +67,12 @@ my $confdesc = { > format => 'mac-addr', > optional => 1, > }, > + wakeonlanaddr => { > + type => 'string', > + description => 'IP Broadcast address for wake on LAN', > + format => 'ip', > + optional => 1, > + },
I'd rather have this in above existing wakeonlan property, as format string, with current mac (as default_key) and new broadcast_addr (or however you'd like to name it there) as optional key. > }; > > my $acmedesc = { > diff --git a/www/manager6/node/CmdMenu.js b/www/manager6/node/CmdMenu.js > index f718f69a..9d266363 100644 > --- a/www/manager6/node/CmdMenu.js > +++ b/www/manager6/node/CmdMenu.js > @@ -103,7 +103,8 @@ Ext.define('PVE.node.CmdMenu', { > Ext.Msg.show({ > title: 'Success', > icon: Ext.Msg.INFO, > - msg: Ext.String.format(gettext("Wake on LAN packet > send for '{0}': '{1}'"), me.nodename, response.result.data) > + msg: Ext.String.format(gettext("Wake on LAN packet > send for '{0}': '{1}' via '{2}'"), > + me.nodename, response.result.data.wakeonlan, > response.result.data.wakeonlanaddr) > }); > } > }); > _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel