From a10dd0b4a21692ea9405e301434f419f420504b1 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 1 Mar 2021 16:42:39 +0100 Subject: [PATCH] fix meraki tags --- .../meraki/cloudcontroller/restapi/mode/devices.pm | 11 +++++++---- .../cloudcontroller/restapi/mode/listdevices.pm | 7 +++++-- .../meraki/cloudcontroller/restapi/mode/listtags.pm | 3 +-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/network/cisco/meraki/cloudcontroller/restapi/mode/devices.pm b/network/cisco/meraki/cloudcontroller/restapi/mode/devices.pm index 96e3c6798..6967c322c 100644 --- a/network/cisco/meraki/cloudcontroller/restapi/mode/devices.pm +++ b/network/cisco/meraki/cloudcontroller/restapi/mode/devices.pm @@ -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}); diff --git a/network/cisco/meraki/cloudcontroller/restapi/mode/listdevices.pm b/network/cisco/meraki/cloudcontroller/restapi/mode/listdevices.pm index 7a4b2863e..ee4e8ee0a 100644 --- a/network/cisco/meraki/cloudcontroller/restapi/mode/listdevices.pm +++ b/network/cisco/meraki/cloudcontroller/restapi/mode/listdevices.pm @@ -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}/); diff --git a/network/cisco/meraki/cloudcontroller/restapi/mode/listtags.pm b/network/cisco/meraki/cloudcontroller/restapi/mode/listtags.pm index f952562cb..641b29296 100644 --- a/network/cisco/meraki/cloudcontroller/restapi/mode/listtags.pm +++ b/network/cisco/meraki/cloudcontroller/restapi/mode/listtags.pm @@ -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 => {},