[pve-devel] [PATCH manager] Add bash completion for wakeonlan API call
Thomas Lamprecht
t.lamprecht at proxmox.com
Fri Jan 25 17:58:08 CET 2019
On 1/25/19 5:03 PM, Christian Ebner wrote:
> This adds the bash completion for the wakeonlan API call.
> The bash completion returns only those nodes which are offline according to the
> member status.
>
> Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
> ---
> PVE/API2/Nodes.pm | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
> index 52f537ba..5d80d4b4 100644
> --- a/PVE/API2/Nodes.pm
> +++ b/PVE/API2/Nodes.pm
> @@ -482,6 +482,17 @@ __PACKAGE__->register_method({
> properties => {
> node => get_standard_option('pve-node', {
> description => 'target node for wake on LAN packet',
> + completion => sub {
> + my $members = PVE::Cluster::get_members();
> + my $res = [];
> + foreach my $node (keys %$members) {
> + if (!$members->{$node}->{online}) {
> + push @$res, $node;
> + }
> + }
> +
> + return $res;
> + }
FYI, an shorter more concise way of doing in this could be:
my $members = PVE::Cluster::get_members();
return [ grep { $members->{$_}->{online} } keys %$members ];
(obv. not tested)
> }),
> },
> },
>
More information about the pve-devel
mailing list