Device-Network-ConfigParser
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Device/Network/ConfigParser/Linux/iproute2.pm view on Meta::CPAN
package Device::Network::ConfigParser::Linux::iproute2;
# ABSTRACT: Parse output from utilities associated with the iproute2 package
our $VERSION = '0.006'; # VERSION
use 5.006;
use strict;
use warnings;
use Modern::Perl;
use Parse::RecDescent;
use Data::Dumper;
use JSON;
use Exporter qw{import};
our @EXPORT_OK = qw{get_parser get_output_drivers parse_config post_process};
=head1 NAME
Device::Network::ConfigParser::Linux::iproute2 - parse output from utilities associated with the iproute2 package.
=head1 VERSION
version 0.006
=head1 SYNOPSIS
This module is intended to be used in conjunction with L<Device::Network::ConfigParser>, however there's nothing stopping it being used on its own.
=head1 SUBROUTINES
=head2 get_parser
For more information on the subroutine, see L<Device::Network::ConfigParser/"get_parser">.
Thos module currently recognised the following output:
=over 4
=item * 'ip route' output
=back
=cut
sub get_parser {
return new Parse::RecDescent(q{
<autoaction: { [@item] }>
startrule: config_line(s) { $item[1] }
config_line: ip_route(s) { { ip_route => $item{'ip_route(s)'} } } |
not_parsed { $item[1] }
ip_route: destination nexthop_ip(?) device proto(?) scope(?) source(?) metric(?) {
{
destination => $item{destination},
next_hop => $item{'nexthop_ip(?)'},
device => $item{device},
proto => $item{proto},
scope => $item{'scope(?)'},
source => $item{'source(?)'},
metric => $item{'metric(?))'}
}
}
destination: ipv4 cidr { { network => $item{ipv4}, cidr => $item{cidr} } } | 'default' { { network => '0.0.0.0', cidr => '0' } }
nexthop_ip: 'via' ipv4 { $item{ipv4} }
device: 'dev' m{[-\w]+} { $item{__PATTERN1__} }
proto: 'proto' m{\w+} { $item{__PATTERN1__} }
scope: 'scope' m{\w+} { $item{__PATTERN1__} }
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.076 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )