blib/lib/Net/Intermapper/Device.pm

filter: Statementstmt 34.4% 90 / 261 Branchbran 0.0% 0 / 100 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 6.3% 5 / 79 Podpod 100% 4 / 4 totaltotal 21.7% 99 / 456 CC 61 SCAR 53.7
CC
61
Cov
24%
header
650.0
toCSV
380.0
toTAB
342.0
CRAP 214.3
« blib/lib/Net/Intermapper/Map.pm ↑ Summary blib/lib/Net/Intermapper.pm »
1 package Net::Intermapper::Device;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 BEGIN {
6 1 ▶ use Exporter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS @HEADERS);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶ $VERSION = '0.03';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 @ISA = qw(Exporter);
10 1 @EXPORT = qw();
11 1 @EXPORT_OK = qw();
12 1 %EXPORT_TAGS = ();
13
14 1 @HEADERS = qw(MapName MapPath Address Id Name Probe Comment Community DisplayIfUnNumbered DNSName IgnoreIfAppleTalk IgnoreIfDiscards IgnoreIfErrors IgnoreOutages AllowPeriodicProbe IMProbe Latitude Longtitude
15 LastTimeDown LastTimeSysUp LastTimeUp MACAddress MapAs MapId MaxTries NetBiosName PctLoss ShortTermPctLoss Availability PollInterval Port Resolve RoundTripTime SNMPv3AuthPassword SNMPv3AuthProtocol
16 SNMPv3PrivPassword SNMPv3PrivProtocol SNMPv3UserName SNMPVersion Status StatusLevel StatusLevelReason SysDescr SysName SysContact SysLocation SysObjectID TimeOut IMID Type ProbeXML SNMPVersionInt
17 SysServices EntServialNum EntMfgName EntModelName DataRetentionPolicy CustomerNameReference EnterpriseID DeviceKind SysUpTime LastModified Parent Acknowledge AckMessage AckExpiration AckTimer VertexID Layer2);
18  
19 };
20  
21 # MOOSE!
22  
23 # I'm lazy.. Yes, there were auto-generated!
24 has 'MapName' => (
25 is => 'rw',
26 isa => 'Str',
27 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
28 1 );
29  
30 has 'MapPath' => (
31 is => 'rw',
32 isa => 'Str',
33 0 ▶ default => sub { "/" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
34 1 );
35  
36 has 'Address' => (
37 is => 'rw',
38 isa => 'Str',
39 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
40 1 );
41  
42 has 'Id' => (
43 is => 'rw',
44 isa => 'Str',
45 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
46 1 );
47  
48 has 'Name' => (
49 is => 'rw',
50 isa => 'Str',
51 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
52 1 );
53  
54 has 'Probe' => (
55 is => 'rw',
56 isa => 'Str',
57 0 ▶ default => sub { "Ping/Echo" }, # SNMP Traffic
Subroutine __ANON__: not called CC=1 SCAR=6.9
58 1 );
59  
60 has 'Comment' => (
61 is => 'rw',
62 isa => 'Str',
63 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
64 1 );
65  
66 has 'Community' => (
67 is => 'rw',
68 isa => 'Str',
69 0 ▶ default => sub { "public" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
70 1 );
71  
72 has 'DisplayIfUnNumbered' => (
73 is => 'rw',
74 isa => 'Str',
75 0 ▶ default => sub { "false" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
76 1 );
77  
78 has 'DNSName' => (
79 is => 'rw',
80 isa => 'Str',
81 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
82 1 );
83  
84 has 'IgnoreIfAppleTalk' => (
85 is => 'rw',
86 isa => 'Str',
87 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
88 1 );
89  
90 has 'IgnoreIfDiscards' => (
91 is => 'rw',
92 isa => 'Str',
93 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
94 1 );
95  
96 has 'IgnoreIfErrors' => (
97 is => 'rw',
98 isa => 'Str',
99 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
100 1 );
101  
102 has 'IgnoreOutages' => (
103 is => 'rw',
104 isa => 'Str',
105 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
106 1 );
107  
108 has 'AllowPeriodicProbe' => (
109 is => 'rw',
110 isa => 'Str',
111 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
112 1 );
113  
114 has 'IMProbe' => (
115 is => 'rw',
116 isa => 'Str',
117 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
118 1 );
119  
120 has 'Latitude' => (
121 is => 'rw',
122 isa => 'Str',
123 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
124 1 );
125  
126 has 'Longtitude' => (
127 is => 'rw',
128 isa => 'Str',
129 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
130 1 );
131  
132 has 'LastTimeDown' => (
133 is => 'rw',
134 isa => 'Str',
135 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
136 1 );
137  
138 has 'LastTimeSysUp' => (
139 is => 'rw',
140 isa => 'Str',
141 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
142 1 );
143  
144 has 'LastTimeUp' => (
145 is => 'rw',
146 isa => 'Str',
147 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
148 1 );
149  
150 has 'MACAddress' => (
151 is => 'rw',
152 isa => 'Str',
153 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
154 1 );
155  
156 has 'MapAs' => (
157 is => 'rw',
158 isa => 'Str',
159 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
160 1 );
161  
162 has 'MapId,' => (
163 is => 'rw',
164 isa => 'Str',
165 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
166 1 );
167  
168 has 'MaxTries' => (
169 is => 'rw',
170 isa => 'Str',
171 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
172 1 );
173  
174 has 'NetBiosName' => (
175 is => 'rw',
176 isa => 'Str',
177 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
178 1 );
179  
180 has 'PctLoss' => (
181 is => 'rw',
182 isa => 'Str',
183 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
184 1 );
185  
186 has 'ShortTermPctLoss' => (
187 is => 'rw',
188 isa => 'Str',
189 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
190 1 );
191  
192 has 'Availability' => (
193 is => 'rw',
194 isa => 'Str',
195 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
196 1 );
197  
198 has 'PollInterval' => (
199 is => 'rw',
200 isa => 'Str',
201 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
202 1 );
203  
204 has 'Port' => (
205 is => 'rw',
206 isa => 'Str',
207 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
208 1 );
209  
210 has 'Resolve' => (
211 is => 'rw',
212 isa => 'Str',
213 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
214 1 );
215  
216 has 'RoundTripTime' => (
217 is => 'rw',
218 isa => 'Str',
219 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
220 1 );
221  
222 has 'SNMPv3AuthPassword' => (
223 is => 'rw',
224 isa => 'Str',
225 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
226 1 );
227  
228 has 'SNMPv3AuthProtocol' => (
229 is => 'rw',
230 isa => 'Str',
231 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
232 1 );
233  
234 has 'SNMPv3PrivPassword' => (
235 is => 'rw',
236 isa => 'Str',
237 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
238 1 );
239  
240 has 'SNMPv3PrivProtocol' => (
241 is => 'rw',
242 isa => 'Str',
243 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
244 1 );
245  
246 has 'SNMPv3UserName' => (
247 is => 'rw',
248 isa => 'Str',
249 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
250 1 );
251  
252 has 'SNMPVersion' => (
253 is => 'rw',
254 isa => 'Str',
255 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
256 1 );
257  
258 has 'Status' => (
259 is => 'rw',
260 isa => 'Str',
261 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
262 1 );
263  
264 has 'StatusLevel' => (
265 is => 'rw',
266 isa => 'Str',
267 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
268 1 );
269  
270 has 'StatusLevelReason' => (
271 is => 'rw',
272 isa => 'Str',
273 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
274 1 );
275  
276 has 'SysDescr' => (
277 is => 'rw',
278 isa => 'Str',
279 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
280 1 );
281  
282 has 'SysName' => (
283 is => 'rw',
284 isa => 'Str',
285 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
286 1 );
287  
288 has 'SysContact' => (
289 is => 'rw',
290 isa => 'Str',
291 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
292 1 );
293  
294 has 'SysLocation' => (
295 is => 'rw',
296 isa => 'Str',
297 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
298 1 );
299  
300 has 'SysObjectID' => (
301 is => 'rw',
302 isa => 'Str',
303 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
304 1 );
305  
306 has 'TimeOut' => (
307 is => 'rw',
308 isa => 'Str',
309 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
310 1 );
311  
312 has 'IMID' => (
313 is => 'rw',
314 isa => 'Str',
315 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
316 1 );
317  
318 has 'Type' => (
319 is => 'rw',
320 isa => 'Str',
321 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
322 1 );
323  
324 has 'ProbeXML' => (
325 is => 'rw',
326 isa => 'Str',
327 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
328 1 );
329  
330 has 'SNMPVersionInt' => (
331 is => 'rw',
332 isa => 'Str',
333 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
334 1 );
335  
336 has 'SysServices' => (
337 is => 'rw',
338 isa => 'Str',
339 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
340 1 );
341  
342 has 'EntServialNum' => (
343 is => 'rw',
344 isa => 'Str',
345 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
346 1 );
347  
348 has 'EntMfgName' => (
349 is => 'rw',
350 isa => 'Str',
351 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
352 1 );
353  
354 has 'EntModelName' => (
355 is => 'rw',
356 isa => 'Str',
357 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
358 1 );
359  
360 has 'DataRetentionPolicy' => (
361 is => 'rw',
362 isa => 'Str',
363 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
364 1 );
365  
366 has 'CustomerNameReference' => (
367 is => 'rw',
368 isa => 'Str',
369 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
370 1 );
371  
372 has 'EnterpriseID' => (
373 is => 'rw',
374 isa => 'Str',
375 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
376 1 );
377  
378 has 'DeviceKind' => (
379 is => 'rw',
380 isa => 'Str',
381 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
382 1 );
383  
384 has 'SysUpTime' => (
385 is => 'rw',
386 isa => 'Str',
387 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
388 1 );
389  
390 has 'LastModified' => (
391 is => 'rw',
392 isa => 'Str',
393 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
394 1 );
395  
396 has 'Parent' => (
397 is => 'rw',
398 isa => 'Str',
399 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
400 1 );
401  
402 has 'Acknowledge' => (
403 is => 'rw',
404 isa => 'Str',
405 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
406 1 );
407  
408 has 'AckMessage' => (
409 is => 'rw',
410 isa => 'Str',
411 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
412 1 );
413  
414 has 'AckExpiration' => (
415 is => 'rw',
416 isa => 'Str',
417 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
418 1 );
419  
420 has 'AckTimer' => (
421 is => 'rw',
422 isa => 'Str',
423 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
424 1 );
425  
426 has 'VertexID' => (
427 is => 'rw',
428 isa => 'Str',
429 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
430 1 );
431  
432 has 'Layer2' => (
433 is => 'rw',
434 isa => 'Str',
435 0 ▶ default => sub { "" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
436 1 );
437  
438 has 'mode' => ( # create, update, delete
439 is => 'rw',
440 isa => 'Str',
441 0 ▶ default => sub { "create"; },
Subroutine __ANON__: not called CC=1 SCAR=6.9
442 1 );
443
444 # No Moose
445
446 sub toXML
447 0 ▶{ my $self = shift;
Subroutine toXML: not called CC=2 SCAR=17.9
Pod documented
448 0 my $id = shift;
449 0 my $result;
450 # Need to build the XML formatting!!
451 0 ▶ if ($id) { $result = " <id>$id</id>\n"; }
Branch: 1 branch
BranchTrueFalseTotal
if ($id) 0 0 0
452 0 return $result;
453 }
454
455 sub toCSV
456 0 ▶{ my $self = shift;
Subroutine toCSV: not called CC=19 SCAR=59.4
Pod documented
457 0 my $id = $self->Id;
458 0 my $result = "";
459 0 my @attributes = $self->meta->get_all_attributes;
460 0 my %attributes = ();
461 0 for my $attribute (@attributes)
462 0 ▶ { $attributes{$attribute->name} = $attribute->get_value($self) || "";
Condition0%0/2
$attribute->get_value($self) || ''
l!l
00
MC/DC0%0/1
$attribute->get_value($self) || ''
$attribute->get_value($self)
Truth table0%0/2
A
A= $attribute->get_value($self)
Aresult
11
00
463 }
464 0 for my $key (@HEADERS)
465 0 ▶ { if ($self->mode eq "create")
Branch: 1 branch
BranchTrueFalseTotal
if ($self->mode eq "create") 0 0 0
466 0 ▶ { next if $key eq "Id";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "Id" 0 0 0
467 0 ▶ next if $key eq "mode";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "mode" 0 0 0
468 0 ▶ next if $key eq "LastTimeDown";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "LastTimeDown" 0 0 0
469 0 ▶ next if $key eq "LastTimeSysUp";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "LastTimeSysUp" 0 0 0
470 0 ▶ next if $key eq "LastTimeUp";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "LastTimeUp" 0 0 0
471 0 ▶ next unless $attributes{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless $attributes{$key} 0 0 0
472 0 $result .= $attributes{$key}.",";
473 }
474 0 ▶ if ($self->mode eq "update")
Branch: 1 branch
BranchTrueFalseTotal
if ($self->mode eq "update") 0 0 0
475 0 ▶ { next if $key eq "mode";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "mode" 0 0 0
476 0 ▶ next if $key eq "LastTimeDown";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "LastTimeDown" 0 0 0
477 0 ▶ next if $key eq "LastTimeSysUp";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "LastTimeSysUp" 0 0 0
478 0 ▶ next if $key eq "LastTimeUp";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "LastTimeUp" 0 0 0
479 0 $result .= $attributes{$key}.",";
480 }
481 0 ▶ if ($self->mode eq "delete")
Branch: 1 branch
BranchTrueFalseTotal
if ($self->mode eq "delete") 0 0 0
482 0 ▶ { next if $key eq "mode";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "mode" 0 0 0
483 0 ▶ next unless $attributes{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless $attributes{$key} 0 0 0
484 0 $result .= $attributes{$key}.",";
485 }
486  
487 }
488 0 chop $result; # Remove the comma of the last field
489 0 $result =~ s/\s$//g;
490 0 $result .= "\r\n";
491 0 return $result;
492 }
493  
494 sub toTAB
495 0 ▶{ my $self = shift;
Subroutine toTAB: not called CC=18 SCAR=58.3
Pod documented
496 0 my $id = $self->Id;
497 0 my $result = "";
498 0 my @attributes = $self->meta->get_all_attributes;
499 0 my %attributes = ();
500 0 for my $attribute (@attributes)
501 0 ▶ { $attributes{$attribute->name} = $attribute->get_value($self) || "";
Condition0%0/2
$attribute->get_value($self) || ''
l!l
00
MC/DC0%0/1
$attribute->get_value($self) || ''
$attribute->get_value($self)
Truth table0%0/2
A
A= $attribute->get_value($self)
Aresult
11
00
502 }
503 0 for my $key (@HEADERS)
504 0 ▶ { if ($self->mode eq "create")
Branch: 1 branch
BranchTrueFalseTotal
if ($self->mode eq "create") 0 0 0
505 0 ▶ { next if $key eq "Id";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "Id" 0 0 0
506 0 ▶ next if $key eq "mode";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "mode" 0 0 0
507 0 ▶ next if $key eq "MapId";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "MapId" 0 0 0
508 0 ▶ next if $key eq "LastTimeDown";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "LastTimeDown" 0 0 0
509 0 ▶ next if $key eq "LastTimeSysUp";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "LastTimeSysUp" 0 0 0
510 0 ▶ next if $key eq "LastTimeUp";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "LastTimeUp" 0 0 0
511 0 ▶ next unless $attributes{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless $attributes{$key} 0 0 0
512 0 $result .= $attributes{$key}."\t";
513 }
514 0 ▶ if ($self->mode eq "update")
Branch: 1 branch
BranchTrueFalseTotal
if ($self->mode eq "update") 0 0 0
515 0 ▶ { next if $key eq "mode";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "mode" 0 0 0
516 0 ▶ next unless $attributes{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless $attributes{$key} 0 0 0
517 0 $result .= $attributes{$key}."\t";
518 }
519 0 ▶ if ($self->mode eq "delete")
Branch: 1 branch
BranchTrueFalseTotal
if ($self->mode eq "delete") 0 0 0
520 0 ▶ { next if $key eq "mode";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "mode" 0 0 0
521 0 ▶ next unless $attributes{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless $attributes{$key} 0 0 0
522 0 $result .= $attributes{"Id"}."\t";
523 0 last;
524 }
525
526 }
527 0 chop $result; # Remove the comma of the last field
528 0 $result =~ s/\s$//g;
529 0 $result .= "\r\n";
530 0 return $result;
531 }
532  
533 sub header
534 0 ▶{ my $self = shift;
Subroutine header: not called CC=25 SCAR=64.8
Pod documented
535 0 ▶ my $format = shift || "";
Condition0%0/2
shift() || ''
l!l
00
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
536 0 my $header = "# format=$format table=devices fields=";
537 0 my @attributes = $self->meta->get_all_attributes;
538 0 my %attributes = ();
539 0 for my $attribute (@attributes)
540 0 ▶ { $attributes{$attribute->name} = $attribute->get_value($self) || "";
Condition0%0/2
$attribute->get_value($self) || ''
l!l
00
MC/DC0%0/1
$attribute->get_value($self) || ''
$attribute->get_value($self)
Truth table0%0/2
A
A= $attribute->get_value($self)
Aresult
11
00
541 }
542 0 for my $key (@HEADERS)
543 0 ▶ { if ($self->mode eq "create")
Branch: 1 branch
BranchTrueFalseTotal
if ($self->mode eq "create") 0 0 0
544 0 ▶ { next if $key eq "Id";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "Id" 0 0 0
545 0 ▶ next if $key eq "mode";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "mode" 0 0 0
546 0 ▶ next if $key eq "LastTimeDown";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "LastTimeDown" 0 0 0
547 0 ▶ next if $key eq "LastTimeSysUp";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "LastTimeSysUp" 0 0 0
548 0 ▶ next if $key eq "LastTimeUp";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "LastTimeUp" 0 0 0
549 0 ▶ next unless $attributes{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless $attributes{$key} 0 0 0
550 0 $header .= $key.",";
551 }
552 0 ▶ if ($self->mode eq "update")
Branch: 1 branch
BranchTrueFalseTotal
if ($self->mode eq "update") 0 0 0
553 0 ▶ { next if $key eq "LastTimeDown";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "LastTimeDown" 0 0 0
554 0 ▶ next if $key eq "LastTimeSysUp";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "LastTimeSysUp" 0 0 0
555 0 ▶ next if $key eq "LastTimeUp";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "LastTimeUp" 0 0 0
556 0 ▶ next if $key eq "mode";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "mode" 0 0 0
557 0 ▶ next unless $attributes{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless $attributes{$key} 0 0 0
558 0 $header .= $key.",";
559 }
560 0 ▶ if ($self->mode eq "delete")
Branch: 1 branch
BranchTrueFalseTotal
if ($self->mode eq "delete") 0 0 0
561 0 ▶ { next if $key eq "LastTimeDown";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "LastTimeDown" 0 0 0
562 0 ▶ next if $key eq "LastTimeSysUp";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "LastTimeSysUp" 0 0 0
563 0 ▶ next if $key eq "LastTimeUp";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "LastTimeUp" 0 0 0
564 0 ▶ next if $key eq "mode";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "mode" 0 0 0
565 0 ▶ next unless $attributes{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless $attributes{$key} 0 0 0
566 0 $header .= $key.",";
567 }
568 }
569 0 ▶ if ($self->mode eq "delete")
Branch: 1 branch
BranchTrueFalseTotal
if ($self->mode eq "delete") 0 0 0
570 0 { $header .= " delete=Id,Address,Name "; } # These 3 fields are used for filtering
571 0 chop $header;
572 0 $header .= "\r\n";
573 0 return $header;
574 }
575  
576
577 =pod
578  
579 =head1 NAME
580  
581 Net::Intermapper::Device - Interface with the HelpSystems Intermapper HTTP API - Devices
582  
583 =head1 SYNOPSIS
584  
585 use Net::Intermapper;
586 my $intermapper = Net::Intermapper->new(hostname=>"10.0.0.1", username=>"admin", password=>"nmsadmin");
587 # Options:
588 # hostname - IP or hostname of Intermapper 5.x and 6.x server
589 # username - Username of Administrator user
590 # password - Password of user
591 # ssl - SSL enabled (1 - default) or disabled (0)
592 # port - TCP port for querying information. Defaults to 8181
593 # modifyport - TCP port for modifying information. Default to 443
594 # cache - Boolean to enable smart caching or force network queries
595  
596 my %users = $intermapper->users;
597 my $users_ref = $intermapper->users;
598 # Retrieve all users from Intermapper, Net::Intermapper::User instances
599 # Returns hash or hashref, depending on context
600
601 my %devices = $intermapper->devices;
602 my $devices_ref = $intermapper->devices;
603 # Retrieve all devices from Intermapper, Net::Intermapper::Device instances
604 # Returns hash or hashref, depending on context
605  
606 my %maps = $intermapper->maps;
607 my $maps_ref = $intermapper->maps;
608 # Retrieve all maps from Intermapper, Net::Intermapper::Map instances
609 # Returns hash or hashref, depending on context
610  
611 my %interfaces = $intermapper->interfaces;
612 my $interfaces_ref = $intermapper->interfaces;
613 # Retrieve all interfaces from Intermapper, Net::Intermapper::Interface instances
614 # Returns hash or hashref, depending on context
615  
616 my %vertices = $intermapper->vertices;
617 my $vertices_ref = $intermapper->vertices;
618 # Retrieve all vertices from Intermapper, Net::Intermapper::Vertice instances
619 # Returns hash or hashref, depending on context
620  
621 my $user = $intermapper->users->{"admin"};
622
623 # Each class will generate specific header. These are typically only for internal use but are compliant to the import format Intermapper uses.
624 print $user->header;
625 print $device->header;
626 print $map->header;
627 print $interface->header;
628 print $vertice->header;
629  
630 print $user->toTAB;
631 print $device->toXML; # This one is broken still!
632 print $map->toCSV;
633 # Works on ALL subclasses
634 # Produce human-readable output of each record in the formats Intermapper supports
635
636 my $user = Net::Intermapper::User->new(Name=>"testuser", Password=>"Test12345");
637 my $response = $intermapper->create($user);
638 # Create new user
639 # Return value is HTTP::Response object
640
641 my $device = Net::Intermapper::Device->new(Name=>"testDevice", MapName=>"TestMap", MapPath=>"/TestMap", Address=>"10.0.0.1");
642 my $response = $intermapper->create($device);
643 # Create new device
644 # Return value is HTTP::Response object
645  
646 $user->Password("Foobar123");
647 my $response = $intermapper->update($user);
648 # Update existing user
649 # Return value is HTTP::Response object
650  
651 my $user = $intermapper->users->{"bob"};
652 my $response = $intermapper->delete($user);
653 # Delete existing user
654 # Return value is HTTP::Response object
655  
656 my $device = $intermapper->devices->{"UniqueDeviceID"};
657 my $response = $intermapper->delete($device);
658 # Delete existing device
659 # Return value is HTTP::Response object
660  
661 my $users = { "Tom" => $tom_user, "Bob" => $bob_user };
662 $intermapper->users($users);
663 # At this point, there is no real reason to do this as update, create and delete work with explicit arguments.
664 # But it can be done with users, devices, interfaces, maps and vertices
665 # Pass a hashref to each method. This will NOT affect the smart-caching (only explicit calls to create, update and delete do this - for now).
666
667 =head1 DESCRIPTION
668  
669 Net::Intermapper::Device is a perl wrapper around the HelpSystems Intermapper API provided through HTTP/HTTPS for access to device information.
670  
671 All calls are handled through an instance of the L<Net::Intermapper> class.
672  
673 use Net::Intermapper;
674 my $intermapper = Net::Intermapper->new(hostname => '10.0.0.1', username => 'admin', password => 'nmsadmin');
675  
676 =head1 USAGE
677  
678 =over 3
679  
680 =item new
681  
682 Class constructor. Returns object of Net::Intermapper::Device on succes. Attributes are:
683  
684 =over 5
685  
686 =item MapName (read-only)
687  
688 Name of the map containing the device.
689  
690 =item MapPath (read-only)
691  
692 Full path of the map containing the device, including the name of the map.
693  
694 =item Address (read-write)
695  
696 The IP or AppleTalk address of the device that is probed by InterMapper. The IP address is represented in dotted-decimal notation, e.g. 'a.b.c.d'. The AppleTalk address is represented in slash notation, e.g. 'a/b'.
697  
698 =item Id (read-only)
699  
700 A unique, persistent identifier for this device instance. The Id will be unique across all maps on a single InterMapper server. This value is used for lookups in the C<users> method in L<Net::Intermapper>.
701  
702 =item Name (read-only)
703  
704 The name of the device. The name is the first non-empty line in a device's label on a map.
705  
706 =item Probe (read-write)
707  
708 The human-readable name of the InterMapper probe.
709  
710 =item Comment (read-write)
711  
712 The comment associated with the device.
713  
714 =item Community (read-write)
715  
716 The SNMP community of the device.
717  
718 =item DisplayIfUnNumbered (read-write)
719  
720 True if the device's behaviour is set to display unnumbered interfaces.
721  
722 =item DNSName (read-write)
723  
724 The fully-qualified DNS name of the device.
725  
726 =item IgnoreIfAppleTalk (read-write)
727  
728 True if the device's behaviour is to ignore AppleTalk interface information.
729  
730 =item IgnoreIfDiscards (read-write)
731  
732 True if the device's behaviour is to ignore interface discards.
733  
734 =item IgnoreIfErrors (read-write)
735  
736 True if the device's behaviour is to ignore interface errors.
737  
738 =item IgnoreOutages (read-write)
739  
740 True if the device's behaviour is to ignore outages.
741  
742 =item AllowPeriodicReprobe (read-write)
743  
744 True if the device's behaviour is to allow periodic reprobe.
745  
746 =item IMProbe (read-write)
747  
748 A special URL representation describing the InterMapper probe and its parameters, e.g. improbe://address:port/...
749  
750 =item Latitude (read-write)
751  
752 The latitude of the device. The value will be a double within the range [-90..90] or empty string if the device does not have this attribute set.
753  
754 =item Longitude (read-write)
755  
756 The longitude of the device. The value will be a double within the range [-180..180] or empty string if the device does not have this attribute set.
757  
758 =item LastTimeDown (read-only)
759  
760 The time when the device last went down. Value is 0 if device has not gone down since we started monitoring it.
761  
762 =item LastTimeSysUp (read-only)
763  
764 The time when the device last came up (ie rebooted), based on the value of sysUpTime. The value is 0 if unknown.
765  
766 =item LastTimeUp (read-only)
767  
768 The time when the device status last transitioned from DOWN to UP. Value is 0 if this has not happened since we started monitoring.
769  
770 =item MACAddress (read-only)
771  
772 The device's MAC Address. If the device has multiple interfaces, this field will contain the MAC Address associated with the device's main IP Address (the same address in the address field).
773  
774 =item MapAs (read-write)
775  
776 Value is one of { ROUTER , SWITCH , HUB, END SYSTEM }
777  
778 =item MapId (read-only)
779  
780 The unique Id of the map file containing the device.
781  
782 =item MaxTries (read-write)
783  
784 The maximum number of attempts to reach the device, typically indicates the maximum number of packets to send during each poll, for packet-based probes.
785  
786 =item NetBIOSName (read-write)
787  
788 The NetBIOS/WINS name of the device.
789  
790 =item PctLoss (read-only)
791  
792 The percent loss (# packets lost/total # packets sent).
793  
794 =item ShortTermPctLoss (read-only)
795  
796 The short-term percent loss (# packets lost/# packets sent).
797  
798 =item Availability (read-only)
799  
800 The percent availability (time up/time monitored).
801  
802 =item PollInterval (read-write)
803  
804 The poll interval of the device, in seconds. Value is 0 if non-polling.
805  
806 =item Port (read-write)
807  
808 The UDP or TCP port number. If the port number is not applicable, this value is always 0. (e.g. for ICMP)
809  
810 =item Resolve (read-write)
811  
812 Value is one of { name , addr , none }.
813  
814 =item RoundTripTime (read-only)
815  
816 The last round-trip time in milliseconds, if known.
817  
818 =item SNMPv3AuthPassword (read-write)
819  
820 The device's SNMPv3 authentication password.
821  
822 =item SNMPv3AuthProtocol (read-write)
823  
824 The device's SNMPv3 authentication protocol (MD5, SHA, None).
825  
826 =item SNMPv3PrivPassword (read-write)
827  
828 The device's SNMPv3 privacy password.
829  
830 =item SNMPv3PrivProtocol (read-write)
831  
832 The device's SNMPv3 privacy protocol (DES, None).
833  
834 =item SNMPv3UserName (read-write)
835  
836 The device's SNMPv3 user name.
837  
838 =item SNMPVersion (read-write)
839  
840 The device's SNMP version (SNMPv1, SNMPv2c, or SNMPv3).
841  
842 =item Status (read-only)
843  
844 The status of the device. The value is one of { 'UP', 'DOWN', 'UNKNOWN' }.
845  
846 =item StatusLevel (read-only)
847  
848 The status level of the device. The value is one of { 'Unknown', 'OK', 'Warning, Acked', 'Warning', 'Alarm, Acked', 'Alarm', 'Critical', 'Critical, Acked', 'Down', 'Down, Acked'}.
849  
850 =item StatusLevelReason (read-only)
851  
852 The reason the device has its status level.
853  
854 =item SysDescr (read-only)
855  
856 The value of sysDescr.
857  
858 =item SysName (read-only)
859  
860 The value of sysName.
861  
862 =item SysContact (read-only)
863  
864 The value of sysContact.
865  
866 =item SysLocation (read-only)
867  
868 The value of sysLocation.
869  
870 =item SysObjectID (read-only)
871  
872 The value of sysObjectID.
873  
874 =item TimeOut (read-write)
875  
876 The timeout of the device, in seconds. Value is 0 if not-applicable to the probe.
877  
878 =item IMID (read-only)
879  
880 Identifier of the device in the IMID format.
881  
882 =item Type (read-only)
883  
884 One of { none, other, snmp, tcp, udp, icmp, cmd, bigbro, ntsvcs }. These values have been updated in 5.0 to match the values used by the database in the probekind field of the devices table.
885  
886 =item ProbeXML (read-only)
887  
888 XML dataset DTD, type='probe'.
889  
890 =item SNMPVersionInt (read-only)
891  
892 1, 2, 3 - SNMP versions. 0 for non-SNMP.
893  
894 =item SysServices (read-only)
895  
896 16-bits integer.
897  
898 =item EntSerialNum (read-only)
899  
900 SnmpAdminString (entPhysicalSerialNum of chassis).
901  
902 =item EntMfgName (read-only)
903  
904 SnmpAdminString (entPhysicalMfgName of chassis).
905  
906 =item EntModelName (read-only)
907  
908 SnmpAdminString (entPhysicalModelName of chassis).
909  
910 =item DataRetentionPolicy (read-only)
911  
912 Data retention policy for IM Database
913  
914 =item CustomerNameReference (read-only)
915  
916 Customer-supplied device name reference, for linking to an external database.
917  
918 =item EnterpriseID (read-only)
919  
920 The value of sysEnterpriseID.
921  
922 =item DeviceKind (read-only)
923  
924 User-specified device type.
925  
926 =item SysUpTime (read-only)
927  
928 System uptime.
929  
930 =item LastModified (read-only)
931  
932 Timestamp of last modification to this device.
933  
934 =item Parent (read-only)
935  
936 Device ID of the parent probe group; this device's id if this device is a probe group; 0 if the device is not part of a probe group.
937  
938 =item Acknowledge (read-write)
939  
940 The acknowledgement state of the device; one of { 'None', 'Basic', 'Maintenance' }. The AckMessage field must also be set to import this field. Indefinite maintenance will be set if AckExpiration is missing and state is set to 'Maintenance'.
941  
942 =item AckMessage (read-write)
943  
944 The message associated with the acknowledge state. If Acknowledge is not set and an AckMessage is supplied, Acknowledge will be set to 'Basic'.
945  
946 =item AckExpiration (read-write)
947  
948 The absolute time when the timed acknowledgement expires, if any. The AckMessage field must also be set to import this field. Acknowledge will be set to 'Maintenance' if not supplied.
949  
950 =item AckTimer (read-only)
951  
952 The time in seconds remaining until the timed acknowledgement expires, if any.
953  
954 =item VertexId (read-only)
955  
956 The Vertex Id of the vertex associated with the device. Matches the VertexId of the corresponding vertex in the vertices table.
957  
958 =item Layer2 (read-only)
959  
960 True if layer2 mapping is enabled for this device.
961  
962 =back
963  
964 =over 3
965  
966 =item header
967  
968 Returns the C<directive> aka data header required by the Intermapper API to perform CRUD actions. This is handled through the C<create>, C<update> and C<delete> method and should not really be used.
969  
970 =back
971  
972 =over 3
973  
974 =item toTAB
975  
976 Returns the object data formatted in TAB delimited format. Used in combination with the C<header> and the C<format> method in L<Net::Intermapper> to perform CRUD actions. This is handled through the C<create>, C<update> and C<delete> method and should not really be used.
977  
978 =back
979  
980 =over 3
981  
982 =item toCSV
983  
984 Returns the object data formatted in Comma Separated delimited format. Used in combination with the C<header> and the C<format> method in L<Net::Intermapper> to perform CRUD actions. This is handled through the C<create>, C<update> and C<delete> method and should not really be used.
985  
986 =back
987  
988 =over 3
989  
990 =item toXML
991  
992 Returns the object data formatted in XML format. Used in combination with the C<header> and the C<format> method in L<Net::Intermapper> to perform CRUD actions. This is handled through the C<create>, C<update> and C<delete> method and should not really be used.
993  
994 =back
995  
996 =over 3
997  
998 =item mode
999  
1000 Internal method to properly format the data and header for CRUD actions. Typically not used.
1001  
1002 =back
1003  
1004 =item $ERROR
1005  
1006 NEEDS TO BE ADDED
1007  
1008 This variable will contain detailed error information.
1009
1010 =back
1011  
1012 =head1 REQUIREMENTS
1013  
1014 For this library to work, you need an instance with Intermapper (obviously) or a simulator like L<Net::Intermapper::Mock>.
1015  
1016 =over 3
1017  
1018 =item L<Moose>
1019  
1020 =item L<IO::Socket::SSL>
1021  
1022 =item L<LWP::UserAgent>
1023  
1024 =item L<XML::Simple>
1025  
1026 =item L<MIME::Base64>
1027  
1028 =item L<URI::Escape>
1029  
1030 =item L<Text::CSV_XS>
1031  
1032 =back
1033
1034 =head1 BUGS
1035  
1036 None so far
1037  
1038 =head1 SUPPORT
1039  
1040 None so far :)
1041  
1042 =head1 AUTHOR
1043  
1044 Hendrik Van Belleghem
1045 CPAN ID: BEATNIK
1046 hendrik.vanbelleghem@gmail.com
1047  
1048 =head1 COPYRIGHT
1049  
1050 This program is free software licensed under the...
1051  
1052 The General Public License (GPL)
1053 Version 2, June 1991
1054  
1055 The full text of the license can be found in the
1056 LICENSE file included with this module.
1057  
1058  
1059 =head1 SEE ALSO
1060  
1061 L<http://download.intermapper.com/docs/UserGuide/Content/09-Reference/09-05-Advanced_Importing/the_directive_line.htm>
1062 L<http://download.intermapper.com/schema/imserverschema.html>
1063  
1064 =cut
1065  
1066 #################### main pod documentation end ###################
1067  
1068 1 __PACKAGE__->meta->make_immutable();
1069  
1070 1 1;
1071 # The preceding line will help the module return a true value
1072  
« blib/lib/Net/Intermapper/Map.pm ↑ Summary blib/lib/Net/Intermapper.pm »