DHCPd/OMAPI/Control.pm

filter: Statementstmt 47.6% 10 / 21 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 2 / 3 Podpod n/a totaltotal 46.1% 12 / 26 CC 3 SCAR 20.3
CC
3
Cov
43%
shutdown_server
12.0
BEGIN
1.0
BEGIN
1.0
CRAP 7.6
« DHCPd/Config/Block.pm ↑ Summary DHCPd/Config/SubClass.pm »
1 package Net::ISC::DHCPd::OMAPI::Control;
2  
3 =head1 NAME
4  
5 Net::ISC::DHCPd::OMAPI::Control - OMAPI control class
6  
7 =head1 SEE ALSO
8  
9 L<Net::ISC::DHCPd::OMAPI::Actions>.
10 L<Net::ISC::DHCPd::OMAPI::Meta::Attribute>.
11  
12 =head1 SYNOPSIS
13  
14 use Net::ISC::DHCPd::OMAPI;
15  
16 $omapi = Net::ISC::DHCPd::OMAPI->new(...);
17 $omapi->connect
18 $control = $omapi->new_object("control", { $attr => $value });
19 $control->read; # retrieve server information
20 $control->$attr($value); # update a value
21 $control->write; # write to server
22  
23 =cut
24  
25 2 ▶use Net::ISC::DHCPd::OMAPI::Sugar;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 2 with 'Net::ISC::DHCPd::OMAPI::Actions';
29  
30 =head1 METHODS
31  
32 =head2 shutdown_server
33  
34 $bool = $self->shutdown_server;
35  
36 Will shutdown the remote server. See C<dhcpd.8> for details.
37  
38 =cut
39  
40 0 ▶sub shutdown_server {
Subroutine shutdown_server: not called CC=3 SCAR=24.8
41 0 my $self = shift;
42 0 my $buffer;
43  
44 0 $self->errstr("");
45  
46 0 for my $cmd ("open", "set state = 2", "update") {
47 0 ($buffer) = $self->_cmd($cmd);
48  
49 0 ▶ unless($buffer =~ /state\s=/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($buffer =~ /state\s=/) 0 0 0
50 0 warn $buffer;
51 0 $self->errstr($buffer);
52 0 return;
53 }
54 }
55  
56 0 $self->parent->disconnect;
57  
58 0 return 1;
59 }
60  
61 2 around shutdown_server => \&Net::ISC::DHCPd::OMAPI::Actions::_around;
62  
63 =head1 ACKNOWLEDGEMENTS
64  
65 Most of the documentation is taken from C<dhcpd(8)>.
66  
67 =head1 COPYRIGHT & LICENSE
68  
69 =head1 AUTHOR
70  
71 See L<Net::ISC::DHCPd>.
72  
73 =cut
74 2 __PACKAGE__->meta->make_immutable;
75 2 1;
« DHCPd/Config/Block.pm ↑ Summary DHCPd/Config/SubClass.pm »