fix meraki tags

This commit is contained in:
garnier-quentin 2021-03-01 16:42:39 +01:00
parent fae986f19b
commit a10dd0b4a2
3 changed files with 13 additions and 8 deletions

View File

@ -463,11 +463,14 @@ sub manage_selection {
$self->{output}->output_add(long_msg => "skipping device '" . $_->{name} . "': no matching filter.", debug => 1); $self->{output}->output_add(long_msg => "skipping device '" . $_->{name} . "': no matching filter.", debug => 1);
next; next;
} }
if (defined($self->{option_results}->{filter_tags}) && $self->{option_results}->{filter_tags} ne '' && if (defined($self->{option_results}->{filter_tags}) && $self->{option_results}->{filter_tags} ne '') {
(!defined($_->{tags}) || $_->{tags} !~ /$self->{option_results}->{filter_tags}/)) { my $tags;
$tags = join(' ', @{$_->{tags}}) if (defined($_->{tags}));
if (!defined($tags) || $tags !~ /$self->{option_results}->{filter_tags}/) {
$self->{output}->output_add(long_msg => "skipping device '" . $_->{name} . "': no matching filter.", debug => 1); $self->{output}->output_add(long_msg => "skipping device '" . $_->{name} . "': no matching filter.", debug => 1);
next; next;
} }
}
my $organization = $options{custom}->get_organization(network_id => $_->{networkId}); my $organization = $options{custom}->get_organization(network_id => $_->{networkId});
if (defined($self->{option_results}->{filter_organization_id}) && $self->{option_results}->{filter_organization_id} ne '' && if (defined($self->{option_results}->{filter_organization_id}) && $self->{option_results}->{filter_organization_id} ne '' &&

View File

@ -63,8 +63,11 @@ sub manage_selection {
foreach (keys %$devices) { foreach (keys %$devices) {
next if (defined($self->{option_results}->{filter_network_id}) && $self->{option_results}->{filter_network_id} ne '' && next if (defined($self->{option_results}->{filter_network_id}) && $self->{option_results}->{filter_network_id} ne '' &&
$devices->{$_}->{networkId} !~ /$self->{option_results}->{filter_network_id}/); $devices->{$_}->{networkId} !~ /$self->{option_results}->{filter_network_id}/);
next if (defined($self->{option_results}->{filter_tags}) && $self->{option_results}->{filter_tags} ne '' && if (defined($self->{option_results}->{filter_tags}) && $self->{option_results}->{filter_tags} ne '') {
(!defined($devices->{$_}->{tags}) || $devices->{$_}->{tags} !~ /$self->{option_results}->{filter_tags}/)); my $tags;
$tags = join(' ', @{$devices->{$_}->{tags}}) if (defined($devices->{$_}->{tags}));
next if (!defined($tags) || $tags !~ /$self->{option_results}->{filter_tags}/);
}
next if (defined($self->{option_results}->{filter_organization_id}) && $self->{option_results}->{filter_organization_id} ne '' && next if (defined($self->{option_results}->{filter_organization_id}) && $self->{option_results}->{filter_organization_id} ne '' &&
$networks->{ $devices->{$_}->{networkId} }->{organizationId} !~ /$self->{option_results}->{filter_organization_id}/); $networks->{ $devices->{$_}->{networkId} }->{organizationId} !~ /$self->{option_results}->{filter_organization_id}/);

View File

@ -70,8 +70,7 @@ sub manage_selection {
next if (defined($self->{option_results}->{filter_organization_name}) && $self->{option_results}->{filter_organization_name} ne '' && next if (defined($self->{option_results}->{filter_organization_name}) && $self->{option_results}->{filter_organization_name} ne '' &&
$organization_name !~ /$self->{option_results}->{filter_organization_name}/); $organization_name !~ /$self->{option_results}->{filter_organization_name}/);
while ($devices->{$_}->{tags} =~ /(\S+)/g) { foreach my $tag (@{$devices->{$_}->{tags}}) {
my $tag = $1;
if (!defined($results->{$tag})) { if (!defined($results->{$tag})) {
$results->{$tag} = { $results->{$tag} = {
network_names => {}, network_names => {},