File Coverage

blib/lib/App/Manoc/Netwalker/Config.pm
Criterion Covered Total %
statement 10 12 83.3
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 14 16 87.5


line stmt bran cond sub pod time code
1             package App::Manoc::Netwalker::Config;
2             #ABSTRACT: Configuration for Manoc Netwalker
3              
4 1     1   810 use Moose;
  1         409536  
  1         7  
5              
6             our $VERSION = '2.99.2'; ##TRIAL VERSION
7              
8 1     1   7157 use namespace::autoclean;
  1         6272  
  1         4  
9              
10 1     1   57 use Moose::Util::TypeConstraints;
  1         2  
  1         9  
11 1     1   2485 use App::Manoc::Utils::Datetime qw(str2seconds);
  0            
  0            
12             use Cwd;
13              
14             subtype 'TimeInterval', as 'Int',
15             where { $_ > 0 },
16             message { "The number you provided, $_, was not a positive number" };
17              
18             coerce 'TimeInterval', from 'Str', via { str2seconds($_) };
19              
20              
21             has manoc_config_dir => (
22             is => 'ro',
23             isa => 'Str',
24             default => sub { getcwd() },
25             );
26              
27              
28             has n_procs => (
29             is => 'rw',
30             isa => 'Int',
31             default => 1,
32             );
33              
34              
35              
36             has default_vlan => (
37             is => 'rw',
38             isa => 'Int',
39             default => 1,
40             );
41              
42              
43             has iface_filter => (
44             is => 'rw',
45             isa => 'Int',
46             default => 1,
47             );
48              
49              
50             has ignore_portchannel => (
51             is => 'rw',
52             isa => 'Bool',
53             default => 1,
54             );
55              
56              
57             has mat_force_vlan => (
58             is => 'rw',
59             isa => 'Maybe[Int]',
60             default => undef,
61             );
62              
63              
64             has force_full_update => (
65             is => 'rw',
66             isa => 'Bool',
67             default => 0,
68             );
69              
70              
71             has snmp_version => (
72             is => 'rw',
73             isa => 'Str',
74             default => '2',
75             );
76              
77              
78             has snmp_community => (
79             is => 'rw',
80             isa => 'Str',
81             default => 'public',
82             );
83              
84              
85             has control_port => (
86             is => 'rw',
87             isa => 'Str',
88             default => '8001',
89             );
90              
91              
92             has remote_control => (
93             is => 'rw',
94             isa => 'Str',
95             default => '127.0.0.1',
96             );
97              
98              
99             has refresh_interval => (
100             is => 'rw',
101             isa => 'TimeInterval',
102             coerce => 1,
103             default => '10m',
104             );
105              
106              
107             has full_update_interval => (
108             is => 'rw',
109             isa => 'TimeInterval',
110             coerce => 1,
111             default => '1h'
112             );
113              
114              
115             has config_update_interval => (
116             is => 'rw',
117             isa => 'TimeInterval',
118             coerce => 1,
119             default => '1d',
120             );
121              
122              
123             has min_backoff_time => (
124             is => 'rw',
125             isa => 'TimeInterval',
126             coerce => 1,
127             default => '5m',
128             );
129              
130              
131             has max_backoff_time => (
132             is => 'rw',
133             isa => 'TimeInterval',
134             coerce => 1,
135             default => '30m',
136             );
137              
138              
139             has 'default_ssh_key' => (
140             is => 'rw',
141             isa => 'Str',
142             builder => '_build_default_ssh_key',
143             );
144              
145             sub _build_default_ssh_key {
146             my $self = shift;
147              
148             my $basedir = $self->manoc_config_dir;
149             foreach (qw( id_dsa id_ecdsa id_ed25519 id_rsa )) {
150             my $file = File::Spec->catfile( $basedir, $_ );
151             -f $file and return $file;
152             }
153             }
154              
155             no Moose;
156             __PACKAGE__->meta->make_immutable;
157              
158             # Local Variables:
159             # mode: cperl
160             # indent-tabs-mode: nil
161             # cperl-indent-level: 4
162             # cperl-indent-parens-as-block: t
163             # End:
164              
165             __END__
166              
167             =pod
168              
169             =head1 NAME
170              
171             App::Manoc::Netwalker::Config - Configuration for Manoc Netwalker
172              
173             =head1 VERSION
174              
175             version 2.99.2
176              
177             =head1 ATTRIBUTES
178              
179             =head2 manoc_config_dir
180              
181             used to construct default paths
182              
183             =head2 n_procs
184              
185             number of concurrent processes for workers
186              
187             =head2 default_vlan
188              
189             The default vlan ID to use when fetching ARP and mac address tables.
190              
191             =head2 default_vlan
192              
193             =head2 iface_filter
194              
195             =head2 ignore_portchannel
196              
197             =head2 mat_force_vlan
198              
199             =head2 force_full_update
200              
201             =head2 snmp_version
202              
203             =head2 snmp_community
204              
205             =head2 control_port
206              
207             =head2 remote_control
208              
209             =head2 refresh_interval
210              
211             =head2 full_update_interval
212              
213             =head2 config_update_interval
214              
215             =head2 min_backoff_time
216              
217             =head2 max_backoff_time
218              
219             =head2 default_ssh_key
220              
221             Default to id_dsa, id_ecdsa, id_ed25519 or id_rsa file on manoc config
222             dir.
223              
224             =head1 AUTHORS
225              
226             =over 4
227              
228             =item *
229              
230             Gabriele Mambrini <gmambro@cpan.org>
231              
232             =item *
233              
234             Enrico Liguori
235              
236             =back
237              
238             =head1 COPYRIGHT AND LICENSE
239              
240             This software is copyright (c) 2017 by Gabriele Mambrini.
241              
242             This is free software; you can redistribute it and/or modify it under
243             the same terms as the Perl 5 programming language system itself.
244              
245             =cut