line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::ISC::DHCPd::Config::FailoverPeer; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::FailoverPeer - Failover Peer Configuration |
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 the block below: |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
$name_attribute_value $value_attribute_value; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
failover peer "$name" { |
17
|
|
|
|
|
|
|
$primary; |
18
|
|
|
|
|
|
|
address dhcp-primary.example.com; |
19
|
|
|
|
|
|
|
port 519; |
20
|
|
|
|
|
|
|
peer address dhcp-secondary.example.com; |
21
|
|
|
|
|
|
|
peer port 520; |
22
|
|
|
|
|
|
|
max-response-delay 60; |
23
|
|
|
|
|
|
|
max-unacked-updates 10; |
24
|
|
|
|
|
|
|
mclt 3600; |
25
|
|
|
|
|
|
|
split 128; |
26
|
|
|
|
|
|
|
load balance max seconds 3; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 SYNOPSIS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
See L<Net::ISC::DHCPd::Config/SYNOPSIS>. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
|
35
|
24
|
|
|
24
|
|
28362
|
use Moose; |
|
24
|
|
|
|
|
61
|
|
|
24
|
|
|
|
|
206
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
with 'Net::ISC::DHCPd::Config::Role'; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 name |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Name of the key - See L</DESCRIPTION> for details. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 arguments |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
This is an array of arguments supplied to the failover peer. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
has arguments => ( |
52
|
|
|
|
|
|
|
traits => ['Hash'], |
53
|
|
|
|
|
|
|
is => 'ro', |
54
|
|
|
|
|
|
|
isa => 'HashRef', |
55
|
|
|
|
|
|
|
default => sub { |
56
|
|
|
|
|
|
|
{ |
57
|
|
|
|
|
|
|
port => { "text" => "port %s", regex => qr/^ \s+ port \s+ (\d+);/x }, |
58
|
|
|
|
|
|
|
peer_port => { "text" => "peer port %s", regex => qr/^ \s+ peer \s+ port \s+ (\d+);/x }, |
59
|
|
|
|
|
|
|
address => { "text" => "address %s", regex => qr/^ \s+ address \s+ (\S+);/x }, |
60
|
|
|
|
|
|
|
peer_address => { "text" => "peer address %s", regex => qr/^ \s+ peer \s+ address \s+ (\S+);/x }, |
61
|
|
|
|
|
|
|
type => { "text" => "%s", regex => qr/^ \s+ (primary|secondary);/x }, |
62
|
|
|
|
|
|
|
max_response_delay => { "text" => "max-response-delay %s", regex => qr/^ \s+ max-response-delay \s+ (\d+);/x }, |
63
|
|
|
|
|
|
|
max_unacked_updates => { "text" => "max-unacked-updates %s", regex => qr/^ \s+ max-unacked-updates \s+ (\d+);/x }, |
64
|
|
|
|
|
|
|
lb_max_seconds => { "text" => "load balance max seconds %s", regex => qr/^ \s+ load\s+balance\s+max\s+seconds \s+ (\d+);/x }, |
65
|
|
|
|
|
|
|
mclt => { "text" => "mclt %s", regex => qr/^ \s+ mclt \s+ (\d+);/x }, |
66
|
|
|
|
|
|
|
split => { "text" => "split %s", regex => qr/^ \s+ split \s+ (\d+);/x }, |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
}, |
69
|
|
|
|
|
|
|
); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
has _order => ( |
72
|
|
|
|
|
|
|
traits => ['Array'], |
73
|
|
|
|
|
|
|
is => 'rw', |
74
|
|
|
|
|
|
|
isa => 'ArrayRef', |
75
|
|
|
|
|
|
|
default => sub { [] }, |
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
has [qw/ peer_port port mclt split lb_max_seconds max_response_delay max_unacked_updates /] => ( |
79
|
|
|
|
|
|
|
is => 'rw', |
80
|
|
|
|
|
|
|
isa => 'Int', |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
has [qw/ name type address peer_address /] => ( |
84
|
|
|
|
|
|
|
is => 'rw', |
85
|
|
|
|
|
|
|
isa => 'Str', |
86
|
|
|
|
|
|
|
); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 regex |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
See L<Net::ISC::DHCPd::Config::Role/regex>. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |
93
|
38
|
|
|
38
|
1
|
282
|
sub regex { qr{^\s* failover \s+ peer \s+ ("?)(\S+)(\1) }x } |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 children |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Modules with slurp need this special children variable to trick the parser |
98
|
|
|
|
|
|
|
into recursively processing them. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut |
101
|
|
|
|
|
|
|
|
102
|
3
|
|
|
3
|
1
|
21
|
sub children { [undef] } |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 METHODS |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 slurp |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This method is used by L<Net::ISC::DHCPd::Config::Role/parse>, and will |
109
|
|
|
|
|
|
|
slurp the content of the function, instead of trying to parse the |
110
|
|
|
|
|
|
|
statements. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=cut |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub slurp { |
115
|
28
|
|
|
28
|
1
|
40
|
my($self, $line) = @_; |
116
|
|
|
|
|
|
|
|
117
|
28
|
|
|
|
|
30
|
while(my ($name, $value) = each (%{$self->arguments})) { |
|
308
|
|
|
|
|
9972
|
|
118
|
280
|
|
|
|
|
333
|
my $regex = $value->{regex}; |
119
|
280
|
100
|
|
|
|
979
|
if ($line =~ $regex) { |
120
|
21
|
|
|
|
|
715
|
$self->$name($1); |
121
|
21
|
|
|
|
|
24
|
push(@{$self->_order}, $name); |
|
21
|
|
|
|
|
690
|
|
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
28
|
100
|
|
|
|
68
|
return 'last' if($line =~ /^\s*}/); |
126
|
25
|
|
|
|
|
56
|
return 'next'; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 captured_to_args |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
See L<Net::ISC::DHCPd::Config::Role/captured_to_args>. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub captured_to_args { |
136
|
3
|
|
|
3
|
1
|
11
|
return { name => $_[1] }; # $_[0] == quote or empty string |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head2 generate |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
See L<Net::ISC::DHCPd::Config::Role/generate>. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=cut |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub generate { |
146
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
147
|
|
|
|
|
|
|
|
148
|
0
|
|
|
|
|
|
my $return = sprintf('failover peer "%s" {', $self->name); |
149
|
0
|
|
|
|
|
|
$return .= "\n"; |
150
|
|
|
|
|
|
|
|
151
|
0
|
|
|
|
|
|
for(@{$self->_order}) { |
|
0
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
|
$return .= sprintf(' '. $self->arguments->{$_}->{text} . ";\n", $self->$_); |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
0
|
|
|
|
|
|
$return .= "}\n"; |
156
|
|
|
|
|
|
|
|
157
|
0
|
|
|
|
|
|
return($return); |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 AUTHOR |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
See L<Net::ISC::DHCPd>. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=cut |
167
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
168
|
|
|
|
|
|
|
1; |