line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::ISC::DHCPd::Types; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Net::ISC::DHCPd::Types - Moose type constraint declaration |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Net::ISC::DHCPd::Types @types; |
10
|
|
|
|
|
|
|
has foo => ( isa => SomeType, ... ); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=cut |
13
|
|
|
|
|
|
|
|
14
|
7
|
|
|
7
|
|
22728
|
use Moose; |
|
7
|
|
|
|
|
462718
|
|
|
7
|
|
|
|
|
66
|
|
15
|
7
|
|
|
7
|
|
49648
|
use MooseX::Types; |
|
7
|
|
|
|
|
104435
|
|
|
7
|
|
|
|
|
62
|
|
16
|
7
|
|
|
7
|
|
29490
|
use MooseX::Types::Moose ':all'; |
|
7
|
|
|
|
|
39103
|
|
|
7
|
|
|
|
|
78
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my @type_list; |
19
|
|
|
|
|
|
|
my @failover_states = ( |
20
|
|
|
|
|
|
|
"na", "partner down", |
21
|
|
|
|
|
|
|
"normal", "communications interrupted", |
22
|
|
|
|
|
|
|
"resolution interrupted", "potential conflict", |
23
|
|
|
|
|
|
|
"recover", "recover done", |
24
|
|
|
|
|
|
|
"shutdown", "paused", |
25
|
|
|
|
|
|
|
"startup", "recover wait", |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
my @states = qw/ |
28
|
|
|
|
|
|
|
na free active expired released |
29
|
|
|
|
|
|
|
abandoned reset backup reserved bootp |
30
|
|
|
|
|
|
|
/; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
BEGIN { |
33
|
7
|
|
|
7
|
|
58445
|
MooseX::Types->import(-declare => [@type_list = qw/ |
34
|
|
|
|
|
|
|
HexInt Ip Mac State Time Statements FailoverState |
35
|
|
|
|
|
|
|
ConfigObject LeasesObject OMAPIObject ProcessObject |
36
|
|
|
|
|
|
|
/]); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 TYPES |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 HexInt |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 Ip |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 Mac |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 State |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 Time |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
subtype State, as Str, |
54
|
|
|
|
|
|
|
where { my $s = $_; return grep { $s eq $_ } @states }; |
55
|
|
|
|
|
|
|
subtype FailoverState, as Str, |
56
|
|
|
|
|
|
|
where { my $s = $_; return grep { $s eq $_ } @failover_states }; |
57
|
|
|
|
|
|
|
subtype HexInt, as Int; |
58
|
|
|
|
|
|
|
subtype Ip, as Str, |
59
|
|
|
|
|
|
|
where { /^[\d.]+$/ }; |
60
|
|
|
|
|
|
|
subtype Mac, as Str, |
61
|
|
|
|
|
|
|
where { /^[a-f0-9:]{17}$/i }; |
62
|
|
|
|
|
|
|
subtype Time, as Int; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
coerce State, ( |
65
|
|
|
|
|
|
|
from Str, via { /(\d+)$/ ? $states[$1] : undef } |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 from_State |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub from_State { |
73
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
74
|
0
|
|
|
|
|
0
|
my $attr = shift; |
75
|
0
|
0
|
|
|
|
0
|
my $value = $self->$attr or return 0; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
0
|
for my $i (0..@states) { |
78
|
0
|
0
|
|
|
|
0
|
return $i if($states[$i] eq $value); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
0
|
return 0; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
coerce FailoverState, ( |
85
|
|
|
|
|
|
|
from Str |
86
|
|
|
|
|
|
|
); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 from_FailoverState |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub from_FailoverState { |
93
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
94
|
0
|
|
|
|
|
0
|
my $attr = shift; |
95
|
0
|
0
|
|
|
|
0
|
my $value = $self->$attr or return 0; |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
0
|
for my $i (0..@failover_states) { |
98
|
0
|
0
|
|
|
|
0
|
return $i if($failover_states[$i] eq $value); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
0
|
return 0; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
coerce HexInt, ( |
105
|
|
|
|
|
|
|
from Str, via { s/://g; hex $_ }, |
106
|
|
|
|
|
|
|
); |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
coerce Ip, ( |
109
|
|
|
|
|
|
|
from Str, via { join ".", map { hex $_ } split /:/ }, |
110
|
|
|
|
|
|
|
); |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
coerce Mac, ( |
113
|
|
|
|
|
|
|
from Str, via { join ":", /(\w\w)/g }, |
114
|
|
|
|
|
|
|
); |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
coerce Time, ( |
117
|
|
|
|
|
|
|
from Str, via { s/://g; hex $_ }, |
118
|
|
|
|
|
|
|
); |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 Statements |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
subtype Statements, as Str, where { /^[\w,]+$/ }; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
coerce Statements, ( |
127
|
|
|
|
|
|
|
from Str, via { s/\s+/,/g; $_; }, |
128
|
|
|
|
|
|
|
from ArrayRef, via { join ",", @$_ }, |
129
|
|
|
|
|
|
|
); |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 ConfigObject |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 LeasesObject |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 OMAPIObject |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 ProcessObject |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
subtype ConfigObject, as Object; |
142
|
|
|
|
|
|
|
subtype LeasesObject, as Object; |
143
|
|
|
|
|
|
|
subtype OMAPIObject, as Object; |
144
|
|
|
|
|
|
|
subtype ProcessObject, as Object; |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
coerce ConfigObject, from HashRef, via { |
147
|
|
|
|
|
|
|
eval "require Net::ISC::DHCPd::Config" or confess $@; |
148
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config->new($_); |
149
|
|
|
|
|
|
|
}; |
150
|
|
|
|
|
|
|
coerce LeasesObject, from HashRef, via { |
151
|
|
|
|
|
|
|
eval "require Net::ISC::DHCPd::Leases" or confess $@; |
152
|
|
|
|
|
|
|
Net::ISC::DHCPd::Leases->new($_); |
153
|
|
|
|
|
|
|
}; |
154
|
|
|
|
|
|
|
coerce OMAPIObject, from HashRef, via { |
155
|
|
|
|
|
|
|
eval "require Net::ISC::DHCPd::OMAPI" or confess $@; |
156
|
|
|
|
|
|
|
Net::ISC::DHCPd::OMAPI->new($_); |
157
|
|
|
|
|
|
|
}; |
158
|
|
|
|
|
|
|
coerce ProcessObject, from HashRef, via { |
159
|
|
|
|
|
|
|
eval "require Net::ISC::DHCPd::Process" or confess $@; |
160
|
|
|
|
|
|
|
Net::ISC::DHCPd::Process->new($_); |
161
|
|
|
|
|
|
|
}; |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head2 get_type_list |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
@names = $class->get_type_list; |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Returns the types defined in this package. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=cut |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub get_type_list { |
172
|
7
|
|
|
7
|
1
|
296
|
return @type_list; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 AUTHOR |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
See L<Net::ISC::DHCPd>. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=cut |
182
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
183
|
|
|
|
|
|
|
1; |