From 31728b58764d842dcf169300802729673f542034 Mon Sep 17 00:00:00 2001 From: qgarnier Date: Thu, 4 Feb 2021 16:53:21 +0100 Subject: [PATCH] Fix #2564 (#2569) --- network/paloalto/ssh/mode/licenses.pm | 13 ++++++++++++- network/paloalto/ssh/plugin.pm | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/network/paloalto/ssh/mode/licenses.pm b/network/paloalto/ssh/mode/licenses.pm index 93f100ffe..824958803 100644 --- a/network/paloalto/ssh/mode/licenses.pm +++ b/network/paloalto/ssh/mode/licenses.pm @@ -86,6 +86,7 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { + 'filter-feature:s' => { name => 'filter_feature' } }); return $self; @@ -105,13 +106,19 @@ sub manage_selection { foreach my $feature (@{$result->{licenses}->{entry}}) { $feature->{expires} = lc($feature->{expires}); + if (defined($self->{option_results}->{filter_feature}) && $self->{option_results}->{filter_feature} ne '' && + $feature->{feature} !~ /$self->{option_results}->{filter_feature}/) { + $self->{output}->output_add(long_msg => "skipping '" . $feature->{feature} . "': no matching feature.", debug => 1); + next; + } + # January 30, 2022 my $dt; if ($feature->{expires} =~ /^(\w+)\s+(\d+).*?(\d+)$/) { $dt = DateTime->new(year => $3, month => $months->{$1}, day => $2); } - $self->{features}->{$feature->{feature}} = { + $self->{features}->{ $feature->{feature} } = { feature => $feature->{feature}, expired => $feature->{expired}, expiry_date => $feature->{expires}, @@ -135,6 +142,10 @@ Check features licensing. =over 8 +=item B<--filter-feature> + +Filter license by feature (can be a regexp). + =item B<--warning-status> Set warning threshold for status. diff --git a/network/paloalto/ssh/plugin.pm b/network/paloalto/ssh/plugin.pm index 10b16144f..5b03d443c 100644 --- a/network/paloalto/ssh/plugin.pm +++ b/network/paloalto/ssh/plugin.pm @@ -39,7 +39,7 @@ sub new { 'system' => 'network::paloalto::ssh::mode::system' }; - $self->{custom_modes}{ssh} = 'network::paloalto::ssh::custom::cli'; + $self->{custom_modes}->{ssh} = 'network::paloalto::ssh::custom::cli'; return $self; }