DHCPd/Config/Subnet.pm

filter: Statementstmt 100% 21 / 21 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 3 / 3 totaltotal 100% 32 / 32 CC 2 SCAR 2.5
CC
2
Cov
100%
__ANON__
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« DHCPd/Config/Host/HardwareEthernet.pm ↑ Summary DHCPd/Config/Authoritative.pm »
1 package Net::ISC::DHCPd::Config::Subnet;
2  
3 =head1 NAME
4  
5 Net::ISC::DHCPd::Config::Subnet - Subnet config parameter
6  
7 =head1 DESCRIPTION
8  
9 See L<Net::ISC::DHCPd::Config::Role> for methods and attributes without
10 documentation.
11  
12 An instance from this class, comes from / will produce:
13  
14 subnet $address_attribute_value \
15 netmask $address_attribute_value {
16 $options_attribute_value
17 $filename_attribute_value
18 $range_attribute_value
19 $pool_attribute_value
20 $hosts_attribute_value
21 }
22  
23 =head1 SYNOPSIS
24  
25 See L<Net::ISC::DHCPd::Config/SYNOPSIS>.
26  
27 =cut
28  
29 27 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 27 ▶use NetAddr::IP;
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 27 with 'Net::ISC::DHCPd::Config::Role';
33  
34 =head2 children
35  
36 See L<Net::ISC::DHCPd::Config/children>.
37  
38 =cut
39  
40 91 ▶sub children {
Subroutine children: called CC=1 SCAR=0.0
Pod documented
41 91 return qw/
42 Net::ISC::DHCPd::Config::Conditional
43 Net::ISC::DHCPd::Config::Host
44 Net::ISC::DHCPd::Config::Pool
45 Net::ISC::DHCPd::Config::Range
46 Net::ISC::DHCPd::Config::Filename
47 Net::ISC::DHCPd::Config::Option
48 Net::ISC::DHCPd::Config::Class
49 Net::ISC::DHCPd::Config::KeyValue
50 Net::ISC::DHCPd::Config::Block
51 Net::ISC::DHCPd::Config::Authoritative
52 /;
53 }
54 27 __PACKAGE__->create_children(__PACKAGE__->children());
55  
56 =head1 ATTRIBUTES
57  
58 =head2 options
59  
60 A list of parsed L<Net::ISC::DHCPd::Config::Option> objects.
61  
62 =head2 ranges
63  
64 A list of parsed L<Net::ISC::DHCPd::Config::Range> objects.
65  
66 =head2 hosts
67  
68 A list of parsed L<Net::ISC::DHCPd::Config::Host> objects.
69  
70 =head2 filenames
71  
72 A list of parsed L<Net::ISC::DHCPd::Config::Filename> objects. There can
73 be only be one node in this list.
74  
75 =cut
76  
77 4 ▶before add_filename => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
78 4 ▶ if(0 < int @{ $_[0]->filenames }) {
Branch: 1 branch
BranchTrueFalseTotal
if (0 < int @{$_[0]->filenames;}) 1 3 4
79 1 confess 'Subnet cannot have more than one filename';
80 }
81 27 };
82  
83 =head2 pools
84  
85 A list of parsed L<Net::ISC::DHCPd::Config::Pool> objects.
86  
87 =head2 address
88  
89 This attribute holds an instance of L<NetAddr::IP>, and represents
90 the ip address of this subnet.
91  
92 =cut
93  
94 27 has address => (
95 is => 'ro',
96 isa => 'Object',
97 );
98  
99 =head2 regex
100  
101 See L<Net::ISC::DHCPd::Config/regex>.
102  
103 =cut
104  
105 27 our $regex = qr{^ \s* subnet \s+ (\S+) \s+ netmask \s+ (\S+) }x;
106  
107 =head1 METHODS
108  
109 =head2 captured_to_args
110  
111 See L<Net::ISC::DHCPd::Config::Role/captured_to_args>.
112  
113 =cut
114  
115 15 ▶sub captured_to_args {
Subroutine captured_to_args: called CC=1 SCAR=0.0
Pod documented
116 15 return { address => NetAddr::IP->new(@_) };
117 }
118  
119 =head2 generate
120  
121 See L<Net::ISC::DHCPd::Config::Role/generate>.
122  
123 =cut
124  
125 4 ▶sub generate {
Subroutine generate: called CC=1 SCAR=0.0
Pod documented
126 4 my $self = shift;
127 4 my $net = $self->address;
128  
129 return(
130 4 'subnet ' .$net->addr .' netmask ' .$net->mask .' {',
131 $self->_generate_config_from_children,
132 '}',
133 );
134 }
135  
136 =head1 COPYRIGHT & LICENSE
137  
138 =head1 AUTHOR
139  
140 See L<Net::ISC::DHCPd>.
141  
142 =cut
143 27 __PACKAGE__->meta->make_immutable;
144 27 1;
« DHCPd/Config/Host/HardwareEthernet.pm ↑ Summary DHCPd/Config/Authoritative.pm »