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

View File

@ -63,8 +63,11 @@ sub manage_selection {
foreach (keys %$devices) {
next if (defined($self->{option_results}->{filter_network_id}) && $self->{option_results}->{filter_network_id} ne '' &&
$devices->{$_}->{networkId} !~ /$self->{option_results}->{filter_network_id}/);
next if (defined($self->{option_results}->{filter_tags}) && $self->{option_results}->{filter_tags} ne '' &&
(!defined($devices->{$_}->{tags}) || $devices->{$_}->{tags} !~ /$self->{option_results}->{filter_tags}/));
if (defined($self->{option_results}->{filter_tags}) && $self->{option_results}->{filter_tags} ne '') {
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 '' &&
$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 '' &&
$organization_name !~ /$self->{option_results}->{filter_organization_name}/);
while ($devices->{$_}->{tags} =~ /(\S+)/g) {
my $tag = $1;
foreach my $tag (@{$devices->{$_}->{tags}}) {
if (!defined($results->{$tag})) {
$results->{$tag} = {
network_names => {},