lib/NBU/Host.pm

filter: Statementstmt 8.6% 24 / 279 Branchbran 0.0% 0 / 110 Conditioncond 0.0% 0 / 18 MC/DCmcdc 0.0% 0 / 11 Subroutinesub 18.1% 6 / 33 Podpod 0.0% 0 / 27 totaltotal 6.2% 30 / 478 CC 62 SCAR 54.3
CC
62
Cov
6%
loadConfig
552.0
loadCoverage
420.0
new
20.0
CRAP 227.8
« lib/NBU/Media.pm ↑ Summary script/policy-list.pl »
1 #
2 # Copyright (c) 2002 Paul Winkeler. All Rights Reserved.
3 # This program is free software; you may redistribute it and/or modify it under
4 # the same terms as Perl itself.
5 #
6 package NBU::Host;
7  
8 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 my %hostList;
12  
13 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶ use Exporter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶ use AutoLoader qw(AUTOLOAD);
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $AUTOLOAD);
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 $VERSION = do { my @r=(q$Revision: 1.33 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r };
18 1 @ISA = qw();
19 1 @EXPORT = qw();
20 1 @EXPORT_OK = qw();
21 1 %EXPORT_TAGS = qw();
22 }
23  
24 my %aliases;
25 0 ▶sub loadAlias {
Subroutine loadAlias: not called CC=1 SCAR=6.9
Pod undocumented
26 0 my $proto = shift;
27 0 my ($alias, $canonical) = @_;
28  
29 0 $aliases{$alias} = $canonical;
30 }
31  
32 0 ▶sub new {
Subroutine new: not called CC=4 SCAR=30.0
Pod undocumented
33 0 my $proto = shift;
34 0 my $host;
35  
36 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
37 0 my $name = shift;
38 0 ▶ $name = $aliases{$name} if (exists($aliases{$name}));
Branch: 1 branch
BranchTrueFalseTotal
if exists $aliases{$name} 0 0 0
39 # my $keyName = substr($name, 0, 12);
40 0 my $keyName = $name;
41  
42 0 ▶ if (!($host = $hostList{$keyName})) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($host = $hostList{$keyName}) 0 0 0
43 0 $host = {};
44 0 bless $host, $proto;
45 0 $host->{NAME} = $name;
46  
47 0 $hostList{$keyName} = $host;
48  
49 0 $host->{ENROLLED} = 0;
50 0 $host->{MM} = 0;
51 0 $host->{MMTYPE} = 0;
52 }
53 }
54 0 return $host;
55 }
56  
57 0 ▶sub populate {
Subroutine populate: not called CC=2 SCAR=17.9
Pod undocumented
58 0 my $proto = shift;
59  
60 0 my $pipe = NBU->cmd("bpclclients -allunique -noheader |");
61 0 ▶ while (<$pipe>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $pipe)) 0 0 0
62 0 my ($platform, $os, $name) = split;
63 0 my $host = NBU::Host->new($name);
64  
65 0 $host->os($os);
66 0 $host->platform($platform);
67 }
68 0 close($pipe);
69 }
70  
71 0 ▶sub byName {
Subroutine byName: not called CC=2 SCAR=17.9
Pod undocumented
72 0 my $proto = shift;
73 0 my $name = shift;
74 0 my $keyName = substr($name, 0, 12);
75  
76 0 ▶ if (my $host = $hostList{$keyName}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $host = $hostList{$keyName}) 0 0 0
77 0 return $host;
78 }
79 0 return undef;
80 }
81  
82 0 ▶sub list {
Subroutine list: not called CC=1 SCAR=6.9
Pod undocumented
83 0 my $proto = shift;
84  
85 0 return (values %hostList);
86 }
87  
88 0 ▶sub enrolled {
Subroutine enrolled: not called CC=1 SCAR=6.9
Pod undocumented
89 0 my $self = shift;
90  
91 0 $self->{ENROLLED} = 1;
92 }
93  
94 0 ▶sub mediaManager {
Subroutine mediaManager: not called CC=2 SCAR=17.9
Pod undocumented
95 0 my $self = shift;
96  
97 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
98 0 $self->{MM} = shift;
99 }
100 0 return $self->{MM};
101 }
102  
103 0 ▶sub roboticMediaManager {
Subroutine roboticMediaManager: not called CC=2 SCAR=17.9
Pod undocumented
104 0 my $self = shift;
105  
106 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
107 0 $self->{MMTYPE} = shift;
108 }
109 0 return $self->{MMTYPE};
110 }
111  
112 0 ▶sub loadClasses {
Subroutine loadClasses: not called CC=1 SCAR=6.9
Pod undocumented
113 0 my $self = shift;
114  
115 0 NBU::Pool->populate;
116  
117 0 my $pipe = NBU->cmd("bpcllist -byclient ".$self->name." -l |");
118 0 NBU::Class->loadClasses($pipe, "CLIENT", $self->clientOf);
119  
120 0 close($pipe);
121 }
122  
123 0 ▶sub makeClassMember {
Subroutine makeClassMember: not called CC=2 SCAR=17.9
Pod undocumented
124 0 my $self = shift;
125 0 my $newClass = shift;
126  
127 0 ▶ if (!defined($self->{CLASSES})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"CLASSES"}) 0 0 0
128 0 $self->{CLASSES} = [];
129 }
130  
131 0 my $classesR = $self->{CLASSES};
132 0 push @$classesR, $newClass;
133  
134 0 return $newClass;
135 }
136  
137 0 ▶sub classes {
Subroutine classes: not called CC=3 SCAR=24.8
Pod undocumented
138 0 my $self = shift;
139  
140 0 ▶ $self->loadClasses if (!$self->{ENROLLED});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"ENROLLED"} 0 0 0
141  
142 0 my $classesR = $self->{CLASSES};
143 0 ▶ if (defined($classesR)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $classesR) 0 0 0
144 0 return (@$classesR);
145 }
146 0 return ();
147 }
148  
149 0 ▶sub name {
Subroutine name: not called CC=1 SCAR=6.9
Pod undocumented
150 0 my $self = shift;
151  
152 0 return $self->{NAME};
153 }
154  
155 0 ▶sub loadConfig {
Subroutine loadConfig: not called CC=23 SCAR=63.1
Pod undocumented
156 0 my $self = shift;
157  
158 0 ▶ return 1 if ($self->{CONFIGLOADED});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"CONFIGLOADED"} 0 0 0
159 0 $self->{PLATFORM} = undef;
160 0 $self->{OS} = undef;
161 0 $self->{NBUVERSION} = undef;
162 0 $self->{RELEASE} = undef;
163 0 $self->{RELEASEID} = undef;
164 0 $self->{CONFIGLOADED} = 1;
165  
166 0 my $pipe = NBU->cmd("bpgetconfig -g ".$self->name." |");
167 0 ▶ unless (defined($_ = <$pipe>)) { close($pipe); return; } chop; s/[\s]*$//;
Branch: 1 branch
BranchTrueFalseTotal
unless (defined($_ = readline $pipe)) 0 0 0
168 0 ▶ if (/Client of ([\S]+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/Client of ([\S]+)/) { } 0 0 0
169 0 $self->{MASTER} = NBU::Host->new($1);
170 0 NBU->addMaster($self->{MASTER});
171 }
172 else {
173 0 $self->{MEDIASERVER} = 1;
174 }
175  
176 # OS on this machine
177 0 ▶ unless (defined($_ = <$pipe>)) { close($pipe); return; } chop; s/[\s]*$//;
Branch: 1 branch
BranchTrueFalseTotal
unless (defined($_ = readline $pipe)) 0 0 0
178 0 ▶ if (/^([\S]+), ([\S]+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^([\S]+), ([\S]+)$/) { } 0 0 0
179 0 $self->{PLATFORM} = $1;
180 0 $self->{OS} = $2;
181 }
182 else {
183 0 $self->{PLATFORM} = $self->{OS} = $_;
184 }
185  
186 # Now get the NetBackup version information
187 # All the hosts in the cluster better be running the same version
188 # but we're not checking for that at this time.
189 0 ▶ unless (defined($_ = <$pipe>)) { close($pipe); return; } chop; s/[\s]*$//;
Branch: 1 branch
BranchTrueFalseTotal
unless (defined($_ = readline $pipe)) 0 0 0
190 0 $self->{NBUVERSION} = $_;
191  
192 # Product identifier
193 0 ▶ unless (defined($_ = <$pipe>)) { close($pipe); return; } chop; s/[\s]*$//;
Branch: 1 branch
BranchTrueFalseTotal
unless (defined($_ = readline $pipe)) 0 0 0
194  
195 0 ▶ if (defined($_ = <$pipe>)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $pipe)) 0 0 0
196 0 chop; s/[\s]*$//;
197 0 $self->{RELEASE} = $_;
198 }
199  
200 0 ▶ if (defined($_ = <$pipe>) && ($_ !~ /^[\s]*$/)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $pipe) and not $_ =~ /^[\s]*$/) { } 0 0 0
Condition0%0/3
defined($_ = readline $pipe) and not $_ =~ /^[\s]*$/
!ll&&!rl&&r
000
MC/DC0%0/2
defined($_ = readline $pipe) and not $_ =~ /^[\s]*$/
defined($_ = readline $pipe) not $_ =~ /^[\s]*$/
Truth table0%0/3
A and not(B)
A= defined($_ = readline $pipe)B= not $_ =~ /^[\s]*$/
ABresult
0X0
100
111
201 0 chop; s/[\s]*$//;
202 0 $self->{RELEASEID} = $_;
203 }
204 else {
205 0 $self->{RELEASEID} = "000000";
206 }
207  
208 0 ▶ if ($self->releaseID >= "450000") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->releaseID >= 450000) 0 0 0
209 # Install path
210 0 ▶ return unless defined($_ = <$pipe>); chop; s/[\s]*$//;
Branch: 1 branch
BranchTrueFalseTotal
unless defined($_ = readline $pipe) 0 0 0
211 # Detailed OS
212 0 ▶ return unless defined($_ = <$pipe>); chop; s/[\s]*$//;
Branch: 1 branch
BranchTrueFalseTotal
unless defined($_ = readline $pipe) 0 0 0
213 0 my ($os, $v) = split;
214 0 $self->{OS} = $os;
215 }
216
217 0 close($pipe);
218  
219 # The -f option used to tell us, when we were media managers,
220 # which host was our master with the "Client of" line. With 4.5 this
221 # feature has been removed. Now we run bpgetconfig against ourselves
222 # and use the "first server in the list must be the master" rule.
223 0 $pipe = NBU->cmd("bpgetconfig -X |");
224 0 ▶ while (<$pipe>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $pipe)) 0 0 0
225 0 ▶ if ((/SERVER = ([\S]+)/) && !defined($self->{MASTER})) {
Branch: 1 branch
BranchTrueFalseTotal
if (/SERVER = ([\S]+)/ and not defined $self->{"MASTER"}) 0 0 0
Condition0%0/3
/SERVER = ([\S]+)/ and not defined $self->{"MASTER"}
!ll&&!rl&&r
000
MC/DC0%0/2
/SERVER = ([\S]+)/ and not defined $self->{"MASTER"}
/SERVER = ([\S]+)/ not defined $self->{"MASTER"}
Truth table0%0/3
A and not(B)
A= /SERVER = ([\S]+)/B= not defined $self->{"MASTER"}
ABresult
0X0
100
111
226 0 $self->{MASTER} = NBU::Host->new($1);
227 }
228 0 ▶ if (/EMMSERVER = ([\S]+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/EMMSERVER = ([\S]+)/) 0 0 0
229 0 $self->{EMMSERVER} = NBU::Host->new($1);
230 }
231 }
232 0 close($pipe);
233  
234 0 my $detailAvailable;
235 0 $pipe = NBU->cmd("bpclient -All -FI |");
236 0 ▶ unless (defined($_ = <$pipe>)) { close($pipe); return; } chop; s/[\s]*$//;
Branch: 1 branch
BranchTrueFalseTotal
unless (defined($_ = readline $pipe)) 0 0 0
237 0 ▶ while (<$pipe>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $pipe)) 0 0 0
238 0 ▶ if (/$self->name/i) {
Branch: 1 branch
BranchTrueFalseTotal
if (/$self->name/i) 0 0 0
239 0 $detailAvailable = 1;
240 0 last;
241 }
242 }
243 0 close($pipe);
244  
245 0 ▶ if ($detailAvailable) {
Branch: 1 branch
BranchTrueFalseTotal
if ($detailAvailable) 0 0 0
246 0 $pipe = NBU->cmd("bpclient -client ".$self->name." -l |");
247 0 ▶ unless (defined($_ = <$pipe>)) { close($pipe); return; } chop; s/[\s]*$//;
Branch: 1 branch
BranchTrueFalseTotal
unless (defined($_ = readline $pipe)) 0 0 0
248 0 close($pipe);
249 }
250 }
251  
252 0 ▶sub clientOf {
Subroutine clientOf: not called CC=1 SCAR=6.9
Pod undocumented
253 0 my $self = shift;
254  
255 0 $self->loadConfig;
256 0 return $self->{MASTER};
257 }
258  
259 0 ▶sub EMMserver {
Subroutine EMMserver: not called CC=1 SCAR=6.9
Pod undocumented
260 0 my $self = shift;
261  
262 0 $self->loadConfig;
263 0 return $self->{EMMSERVER};
264 }
265  
266 0 ▶sub platform {
Subroutine platform: not called CC=2 SCAR=17.9
Pod undocumented
267 0 my $self = shift;
268  
269 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
270 0 $self->{PLATFORM} = shift;
271 }
272 else {
273 0 $self->loadConfig;
274 }
275  
276 0 return $self->{PLATFORM};
277 }
278  
279 0 ▶sub os {
Subroutine os: not called CC=2 SCAR=17.9
Pod undocumented
280 0 my $self = shift;
281  
282 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
283 0 $self->{OS} = shift;
284 }
285 else {
286 0 $self->loadConfig;
287 }
288  
289 0 return $self->{OS};
290 }
291  
292 0 ▶sub NBUVersion {
Subroutine NBUVersion: not called CC=2 SCAR=17.9
Pod undocumented
293 0 my $self = shift;
294  
295 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
296 0 $self->{NBUVERSION} = shift;
297 }
298 else {
299 0 $self->loadConfig;
300 }
301  
302 0 return $self->{NBUVERSION};
303 }
304  
305 0 ▶sub NBUmajorVersion {
Subroutine NBUmajorVersion: not called CC=1 SCAR=6.9
Pod undocumented
306 0 my $self = shift;
307  
308 0 $self->NBUVersion =~ /^([\d])\.([\d\.]*$)/;
309 0 return $1;
310 }
311  
312 0 ▶sub IPaddress {
Subroutine IPaddress: not called CC=2 SCAR=17.9
Pod undocumented
313 0 my $self = shift;
314  
315 0 ▶ if (!defined($self->{IPADDRESS})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"IPADDRESS"}) 0 0 0
316 0 my $rawAddress = (gethostbyname($self->name))[4];
317 0 my @octets = unpack("C4", $rawAddress);
318 0 $self->{IPADDRESS} = join(".", @octets);
319 }
320  
321 0 return $self->{IPADDRESS};
322 }
323  
324 0 ▶sub release {
Subroutine release: not called CC=2 SCAR=17.9
Pod undocumented
325 0 my $self = shift;
326  
327 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
328 0 $self->{RELEASE} = shift;
329 }
330 else {
331 0 $self->loadConfig;
332 }
333  
334 0 return $self->{RELEASE};
335 }
336  
337 0 ▶sub releaseID {
Subroutine releaseID: not called CC=2 SCAR=17.9
Pod undocumented
338 0 my $self = shift;
339  
340 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
341 0 $self->{RELEASEID} = shift;
342 }
343 else {
344 0 $self->loadConfig;
345 }
346  
347 0 return $self->{RELEASEID};
348 }
349  
350 0 ▶sub loadCoverage {
Subroutine loadCoverage: not called CC=20 SCAR=60.4
Pod undocumented
351 0 my $self = shift;
352 0 my $name = $self->name;
353  
354 0 my %coverage;
355 my $loadOK;
356  
357 0 my $pipe = NBU->cmd("bpcoverage -c $name -no_cov_header -no_hw_header |");
358 0 ▶ while (<$pipe>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $pipe)) 0 0 0
359 0 ▶ if (!$loadOK) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $loadOK) { } 0 0 0
elsif ($loadOK and not /^[\s]*$/ and not / Exit status/) { } 0 0 0
360 0 ▶ if (/^CLIENT: $name/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^CLIENT: $name/) 0 0 0
361 0 ▶ while (<$pipe>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $pipe)) 0 0 0
362 0 ▶ last if (/Mount Point/ || /Drive Letter/);
Branch: 1 branch
BranchTrueFalseTotal
if /Mount Point/ or /Drive Letter/ 0 0 0
Condition0%0/3
/Mount Point/ or /Drive Letter/
l!l&&r!l&&!r
000
MC/DC0%0/2
/Mount Point/ or /Drive Letter/
/Mount Point/ /Drive Letter/
Truth table0%0/3
A or B
A= /Mount Point/B= /Drive Letter/
ABresult
1X1
011
000
363 }
364 0 $_ = <$pipe>;
365 0 $loadOK = 1;
366 }
367 }
368 ▶ elsif ($loadOK && !(/^[\s]*$/) && !(/ Exit status/)) {
Condition0%0/6
$loadOK and not /^[\s]*$/ and not / Exit status/
!ll&&!rl&&r
000
$loadOK and not /^[\s]*$/
!ll&&!rl&&r
000
MC/DC0%0/3
$loadOK and not /^[\s]*$/ and not / Exit status/
$loadOK not /^[\s]*$/ not / Exit status/
Truth table0%0/4
A and not(B) and not(C)
A= $loadOKB= not /^[\s]*$/C= not / Exit status/
ABCresult
0XX0
10X0
1100
1111
369 #
370 # Preserve input line in local variable because some methods called below
371 # open other streams and thus clobber the global $_!
372 0 my $l = $_;
373  
374 0 ▶ if ($self->os =~ /rs6000_42|SunOS|[Ss]olaris|linux|hp10.20/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->os =~ /rs6000_42|SunOS|[Ss]olaris|linux|hp10.20/) { } 0 0 0
elsif ($self->os =~ /Windows(NET|NT|2000|2003|XP)/) { } 0 0 0
375 0 $_ = $l;
376 0 my ($mountPoint, @remainder) = split;
377 0 my ($deviceFile, $className, $status) = @remainder;
378  
379 0 ▶ next if ($deviceFile !~ /^\//);
Branch: 1 branch
BranchTrueFalseTotal
unless $deviceFile =~ m[^/] 0 0 0
380  
381 0 ▶ if ($className eq "UNCOVERED") {
Branch: 1 branch
BranchTrueFalseTotal
if ($className eq 'UNCOVERED') { } 0 0 0
382 0 $coverage{$mountPoint} = undef;
383 }
384 else {
385 0 $className =~ s/^\*//;
386 0 my $clR = $coverage{$mountPoint};
387 0 ▶ if (!$clR) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($clR) 0 0 0
388 0 $coverage{$mountPoint} = $clR = [];
389 }
390 0 my $class = NBU::Class->byName($className, $self->clientOf);
391 0 $class->providesCoverage(1);
392 0 push @$clR, $class;
393 }
394 }
395 elsif ($self->os =~ /Windows(NET|NT|2000|2003|XP)/) {
396 0 $_ = $l;
397 0 s/^[\s]*([\S].*:.)//; my $mountPoint = $1;
398 0 my (@remainder) = split;
399 0 my $deviceFile;
400  
401 0 ▶ if ((($self->releaseID eq "451000") && defined($self->{MEDIASERVER}))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->releaseID eq 451000 and defined $self->{"MEDIASERVER"}) 0 0 0
Condition0%0/3
$self->releaseID eq 451000 and defined $self->{"MEDIASERVER"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->releaseID eq 451000 and defined $self->{"MEDIASERVER"}
$self->releaseID eq 451000 defined $self->{"MEDIASERVER"}
Truth table0%0/3
A and B
A= $self->releaseID eq 451000B= defined $self->{"MEDIASERVER"}
ABresult
0X0
100
111
402 0 $deviceFile = shift @remainder;
403 }
404 0 my ($className, $status) = @remainder;
405 0 ▶ if ($className eq "UNCOVERED") {
Branch: 1 branch
BranchTrueFalseTotal
if ($className eq 'UNCOVERED') { } 0 0 0
406 0 $coverage{$mountPoint} = undef;
407 }
408 else {
409 0 $className =~ s/^\*//;
410 0 my $clR = $coverage{$mountPoint};
411 0 ▶ if (!$clR) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($clR) 0 0 0
412 0 $coverage{$mountPoint} = $clR = [];
413 }
414 0 my $class = NBU::Class->byName($className, $self->clientOf);
415 0 ▶ print STDERR "Unknown class referenced: $className\n" if (!defined($class));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $class 0 0 0
416 0 $class->providesCoverage(1);
417 0 push @$clR, $class;
418 }
419 }
420 else {
421 0 print "coverage from ".$self->os.": $_";
422 }
423 }
424 else {
425 0 last;
426 }
427 }
428 0 close($pipe);
429  
430 0 $self->{COVERAGE} = \%coverage;
431 }
432  
433 0 ▶sub coverage {
Subroutine coverage: not called CC=2 SCAR=17.9
Pod undocumented
434 0 my $self = shift;
435  
436 0 ▶ if (!$self->{COVERAGE}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"COVERAGE"}) 0 0 0
437 0 $self->loadCoverage;
438 }
439  
440 0 my $coverageR = $self->{COVERAGE};
441 0 return (%$coverageR);
442 }
443  
444 #
445 # Add an image to a host's list of backup images
446 0 ▶sub addImage {
Subroutine addImage: not called CC=2 SCAR=17.9
Pod undocumented
447 0 my $self = shift;
448 0 my $image = shift;
449
450 0 ▶ $self->{IMAGES} = {} if (!defined($self->{IMAGES}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"IMAGES"} 0 0 0
451  
452 0 my $images = $self->{IMAGES};
453  
454 0 $$images{$image->id} = $image;
455 }
456  
457 #
458 # Load the list of images run against this host
459 0 ▶sub loadImages {
Subroutine loadImages: not called CC=2 SCAR=17.9
Pod undocumented
460 0 my $self = shift;
461  
462 0 ▶ if (!defined($self->{ALLIMAGES})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"ALLIMAGES"}) 0 0 0
463 0 NBU::Image->loadImages(NBU->cmd("bpimmedia -l -client ".$self->name." |"));
464 }
465 0 return ($self->{ALLIMAGES} = $self->{IMAGES});
466 }
467  
468 0 ▶sub images {
Subroutine images: not called CC=2 SCAR=17.9
Pod undocumented
469 0 my $self = shift;
470  
471 0 $self->loadImages;
472  
473 0 ▶ if (defined(my $images = $self->{IMAGES})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $images = $self->{'IMAGES'})) { } 0 0 0
474 0 return (values %$images);
475 }
476 else {
477 0 return ();
478 }
479 }
480  
481 1 1;
482  
483 __END__
« lib/NBU/Media.pm ↑ Summary script/policy-list.pl »