blib/lib/RackMan/Format/PXE.pm

filter: Statementstmt 45.7% 16 / 35 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 83.3% 5 / 6 Podpod 100% 1 / 1 totaltotal 43.1% 22 / 51 CC 4 SCAR 22.5
CC
4
Cov
38%
write
20.0
BEGIN
1.0
BEGIN
1.0
CRAP 9.4
« blib/lib/RackMan.pm ↑ Summary blib/lib/RackMan/Format/LDAP.pm »
1 package RackMan::Format::PXE;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use RackMan::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use RackMan::Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8  
9 2 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 CONFIG_SECTION => "format:pxe",
11 DEFAULT_PATH => "/etc/pxe/hosts",
12 TEMPLATE_PATH => "/etc/pxe/host.pxe.conf.tmpl",
13 2 };
14  
15  
16 #
17 # write()
18 # -----
19 0 ▶sub write {
Subroutine write: not called CC=4 SCAR=30.0
Pod documented
20 0 my ($class, $args) = @_;
21  
22 0 my $rackdev = $args->{rackdev};
23 0 my $rackman = $args->{rackman};
24 0 my $config = RackMan::File->new;
25  
26 # fetch the list of regular MAC addresses
27 0 my @mac_addrs = $rackdev->regular_mac_addrs;
28  
29 # load and populate the template
30 my $tmpl_path = $rackman->options->{pxe_template}
31 0 ▶ || $rackman->config->val(CONFIG_SECTION, "template", TEMPLATE_PATH);
Condition0%0/3
$rackman->options->{'pxe_template'} || $rackman->config->val('format:pxe', 'template', '/etc/pxe/host.pxe.conf.tmpl')
l!l&&r!l&&!r
000
MC/DC0%0/2
$rackman->options->{'pxe_template'} || $rackman->config->val('format:pxe', 'template', '/etc/pxe/host.pxe.conf.tmpl')
$rackman->options->{'pxe_template'} $rackman->config->val('format:pxe', 'template', '/etc/pxe/host.pxe.conf.tmpl')
Truth table0%0/3
A || B
A= $rackman->options->{'pxe_template'}B= $rackman->config->val('format:pxe', 'template', '/etc/pxe/host.pxe.conf.tmpl')
ABresult
1X1
011
000
32 0 ▶ print " = reading $tmpl_path\n" if $args->{verbose};
Branch: 1 branch
BranchTrueFalseTotal
if $args->{"verbose"} 0 0 0
33 0 my $tmpl = RackMan::Template->new(filename => $tmpl_path);
34 0 $tmpl->populate_from($rackdev, $rackman);
35  
36 # generate the config
37 0 $config->add_content($tmpl->output);
38  
39 # write the configuration on disk
40 0 (my $config_name = lc "01-$mac_addrs[0]{l2address_text}") =~ s/:/-/g;
41 0 $config->name($config_name);
42 0 $config->path($rackman->config->val(CONFIG_SECTION, "path", DEFAULT_PATH));
43 0 ▶ print " + writing ", $config->fullpath, $/ if $args->{verbose};
Branch: 1 branch
BranchTrueFalseTotal
if $args->{"verbose"} 0 0 0
44 0 my $scm = $rackman->get_scm({ path => $config->path });
45 0 $scm->update;
46 0 $config->write;
47 0 $scm->add($config->name);
48 0 $scm->commit($config->name, "generated by $class / $::PROGRAM v$::VERSION");
49 }
50  
51  
52 2 __PACKAGE__
53  
54 __END__
« blib/lib/RackMan.pm ↑ Summary blib/lib/RackMan/Format/LDAP.pm »