Skip to content
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

enh(meraki-cloudcontroller-restapi): add --filter-model to discovery mode #5357

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ sub new {
'filter-network-id:s' => { name => 'filter_network_id' },
'filter-organization-name:s' => { name => 'filter_organization_name' },
'filter-organization-id:s' => { name => 'filter_organization_id' },
'filter-model:s' => { name => 'filter_model' },
'filter-tags:s' => { name => 'filter_tags' }
});

Expand Down Expand Up @@ -70,14 +71,16 @@ sub discovery_devices {

my @results;
foreach (values %$devices) {
next if (defined($self->{option_results}->{filter_network_id}) && $self->{option_results}->{filter_network_id} ne '' &&
$_->{networkId} !~ /$self->{option_results}->{filter_network_id}/);
next if (defined($self->{option_results}->{filter_tags}) && $self->{option_results}->{filter_tags} ne '' &&
(!defined($_->{tags}) || $_->{tags} !~ /$self->{option_results}->{filter_tags}/));
next if (defined($self->{option_results}->{filter_organization_id}) && $self->{option_results}->{filter_organization_id} ne '' &&
$_->{orgId} !~ /$self->{option_results}->{filter_organization_id}/);
next if (defined($self->{option_results}->{filter_organization_name}) && $self->{option_results}->{filter_organization_name} ne '' &&
$options{organizations}->{ $_->{orgId} }->{name} !~ /$self->{option_results}->{filter_organization_name}/);
next if ( !centreon::plugins::misc::is_empty($self->{option_results}->{filter_model})
&& $_->{model} !~ /$self->{option_results}->{filter_model}/);
next if ( !centreon::plugins::misc::is_empty($self->{option_results}->{filter_network_id})
&& $_->{networkId} !~ /$self->{option_results}->{filter_network_id}/);
next if ( !centreon::plugins::misc::is_empty($self->{option_results}->{filter_tags})
&& (!defined($_->{tags}) || $_->{tags} !~ /$self->{option_results}->{filter_tags}/));
next if ( !centreon::plugins::misc::is_empty($self->{option_results}->{filter_organization_id})
&& $_->{orgId} !~ /$self->{option_results}->{filter_organization_id}/);
next if ( !centreon::plugins::misc::is_empty($self->{option_results}->{filter_organization_name})
&& $options{organizations}->{ $_->{orgId} }->{name} !~ /$self->{option_results}->{filter_organization_name}/);

my $node = {
name => $_->{name},
Expand Down Expand Up @@ -200,27 +203,36 @@ Resources discovery.

=item B<--prettify>

Prettify JSON output.
Prettify the JSON output.

=item B<--resource-type>

Choose the type of resources to discover (can be: 'device', 'network').
Define the type of resources to discover (C<device> or C<network>).

=item B<--filter-model>

Define which resources should be discovered based on the resource's model.
This option will be treated as a regular expression.

=item B<--filter-network-id>

Filter by network ID (can be a regexp).
Define which resources should be discovered based on the resource's network ID.
This option will be treated as a regular expression.

=item B<--filter-organization-id>

Filter by organization ID (can be a regexp).
Define which resources should be discovered based on the resource's organization ID.
This option will be treated as a regular expression.

=item B<--filter-organization-name>

Filter by organization name (can be a regexp).
Define which resources should be discovered based on the resource's organization name.
This option will be treated as a regular expression.

=item B<--filter-tags>

Filter by tags (can be a regexp).
Define which resources should be discovered based on the resource's tags.
This option will be treated as a regular expression.

=back

Expand Down
Loading