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.02';
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 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  
595 print Dumper $intermapper->users;
596 # Retrieve all users from Intermapper
597 # Returns hash with user name / Net::Intermapper::User pairs
598
599 print Dumper $intermapper->devices;
600 # Retrieve all devices from Intermapper
601 # Returns hash with device name / Net::Intermapper::Device pairs
602
603 print Dumper $intermapper->maps;
604 # Retrieve all maps from Intermapper
605 # Returns hash with map name / Net::Intermapper::Map pairs
606
607 print Dumper $intermapper->interfaces;
608 # Retrieve all interfaces from Intermapper
609 # Returns hash with interface ID / Net::Intermapper::Interface pairs
610
611 print Dumper $intermapper->vertices;
612 # Retrieve all vertices from Intermapper
613 # Returns hash with name / Net::Intermapper::Vertice pairs
614  
615 my $user = $intermapper->users->{"admin"};
616 print $user->header;
617 # Generate 'directive' needed for manipulation. Mostly used internally.
618 # $user->mode("create"); # This changes the header fields
619 # $user->mode("update"); # This also changes the header fields
620 # Both are NOT needed when adding or updating a record
621 print $user->toTAB;
622 print $user->toXML;
623 print $user->toCSV;
624 # Produce human-readable output of each record.
625
626 my $user = Net::Intermapper::User->new(Name=>"testuser", Password=>"Test12345");
627 print Dumper $intermapper->create($user);
628 # Create new user
629
630 my $device = Net::Intermapper::Device->new(Name=>"testDevice", MapName=>"TestMap", MapPath=>"/TestMap", Address=>"10.0.0.1");
631 print Dumper $intermapper->create($device);
632 # Create new device
633  
634 $user->Password("Foobar123");
635 $intermapper->update($user);
636 # Update existing user
637  
638 my $user = $intermapper->users->{"bob"};
639 intermapper->delete($user);
640 Delete existing user
641  
642 my $device = $intermapper->devices->{"UniqueDeviceId"};
643 $intermapper->delete($device);
644 # Delete existing device
645
646 =head1 DESCRIPTION
647  
648 Net::Intermapper::Device is a perl wrapper around the HelpSystems Intermapper API provided through HTTP/HTTPS for access to device information.
649  
650 All calls are handled through an instance of the L<Net::Intermapper> class.
651  
652 use Net::Intermapper;
653 my $intermapper = Net::Intermapper->new(hostname => '10.0.0.1', username => 'admin', password => 'nmsadmin');
654  
655 =head1 USAGE
656  
657 =over 3
658  
659 =item new
660  
661 Class constructor. Returns object of Net::Intermapper::Device on succes. Attributes are:
662  
663 =over 5
664  
665 =item MapName (read-only)
666  
667 Name of the map containing the device.
668  
669 =item MapPath (read-only)
670  
671 Full path of the map containing the device, including the name of the map.
672  
673 =item Address (read-write)
674  
675 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'.
676  
677 =item Id (read-only)
678  
679 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>.
680  
681 =item Name (read-only)
682  
683 The name of the device. The name is the first non-empty line in a device's label on a map.
684  
685 =item Probe (read-write)
686  
687 The human-readable name of the InterMapper probe.
688  
689 =item Comment (read-write)
690  
691 The comment associated with the device.
692  
693 =item Community (read-write)
694  
695 The SNMP community of the device.
696  
697 =item DisplayIfUnNumbered (read-write)
698  
699 True if the device's behaviour is set to display unnumbered interfaces.
700  
701 =item DNSName (read-write)
702  
703 The fully-qualified DNS name of the device.
704  
705 =item IgnoreIfAppleTalk (read-write)
706  
707 True if the device's behaviour is to ignore AppleTalk interface information.
708  
709 =item IgnoreIfDiscards (read-write)
710  
711 True if the device's behaviour is to ignore interface discards.
712  
713 =item IgnoreIfErrors (read-write)
714  
715 True if the device's behaviour is to ignore interface errors.
716  
717 =item IgnoreOutages (read-write)
718  
719 True if the device's behaviour is to ignore outages.
720  
721 =item AllowPeriodicReprobe (read-write)
722  
723 True if the device's behaviour is to allow periodic reprobe.
724  
725 =item IMProbe (read-write)
726  
727 A special URL representation describing the InterMapper probe and its parameters, e.g. improbe://address:port/...
728  
729 =item Latitude (read-write)
730  
731 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.
732  
733 =item Longitude (read-write)
734  
735 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.
736  
737 =item LastTimeDown (read-only)
738  
739 The time when the device last went down. Value is 0 if device has not gone down since we started monitoring it.
740  
741 =item LastTimeSysUp (read-only)
742  
743 The time when the device last came up (ie rebooted), based on the value of sysUpTime. The value is 0 if unknown.
744  
745 =item LastTimeUp (read-only)
746  
747 The time when the device status last transitioned from DOWN to UP. Value is 0 if this has not happened since we started monitoring.
748  
749 =item MACAddress (read-only)
750  
751 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).
752  
753 =item MapAs (read-write)
754  
755 Value is one of { ROUTER , SWITCH , HUB, END SYSTEM }
756  
757 =item MapId (read-only)
758  
759 The unique Id of the map file containing the device.
760  
761 =item MaxTries (read-write)
762  
763 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.
764  
765 =item NetBIOSName (read-write)
766  
767 The NetBIOS/WINS name of the device.
768  
769 =item PctLoss (read-only)
770  
771 The percent loss (# packets lost/total # packets sent).
772  
773 =item ShortTermPctLoss (read-only)
774  
775 The short-term percent loss (# packets lost/# packets sent).
776  
777 =item Availability (read-only)
778  
779 The percent availability (time up/time monitored).
780  
781 =item PollInterval (read-write)
782  
783 The poll interval of the device, in seconds. Value is 0 if non-polling.
784  
785 =item Port (read-write)
786  
787 The UDP or TCP port number. If the port number is not applicable, this value is always 0. (e.g. for ICMP)
788  
789 =item Resolve (read-write)
790  
791 Value is one of { name , addr , none }.
792  
793 =item RoundTripTime (read-only)
794  
795 The last round-trip time in milliseconds, if known.
796  
797 =item SNMPv3AuthPassword (read-write)
798  
799 The device's SNMPv3 authentication password.
800  
801 =item SNMPv3AuthProtocol (read-write)
802  
803 The device's SNMPv3 authentication protocol (MD5, SHA, None).
804  
805 =item SNMPv3PrivPassword (read-write)
806  
807 The device's SNMPv3 privacy password.
808  
809 =item SNMPv3PrivProtocol (read-write)
810  
811 The device's SNMPv3 privacy protocol (DES, None).
812  
813 =item SNMPv3UserName (read-write)
814  
815 The device's SNMPv3 user name.
816  
817 =item SNMPVersion (read-write)
818  
819 The device's SNMP version (SNMPv1, SNMPv2c, or SNMPv3).
820  
821 =item Status (read-only)
822  
823 The status of the device. The value is one of { 'UP', 'DOWN', 'UNKNOWN' }.
824  
825 =item StatusLevel (read-only)
826  
827 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'}.
828  
829 =item StatusLevelReason (read-only)
830  
831 The reason the device has its status level.
832  
833 =item SysDescr (read-only)
834  
835 The value of sysDescr.
836  
837 =item SysName (read-only)
838  
839 The value of sysName.
840  
841 =item SysContact (read-only)
842  
843 The value of sysContact.
844  
845 =item SysLocation (read-only)
846  
847 The value of sysLocation.
848  
849 =item SysObjectID (read-only)
850  
851 The value of sysObjectID.
852  
853 =item TimeOut (read-write)
854  
855 The timeout of the device, in seconds. Value is 0 if not-applicable to the probe.
856  
857 =item IMID (read-only)
858  
859 Identifier of the device in the IMID format.
860  
861 =item Type (read-only)
862  
863 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.
864  
865 =item ProbeXML (read-only)
866  
867 XML dataset DTD, type='probe'.
868  
869 =item SNMPVersionInt (read-only)
870  
871 1, 2, 3 - SNMP versions. 0 for non-SNMP.
872  
873 =item SysServices (read-only)
874  
875 16-bits integer.
876  
877 =item EntSerialNum (read-only)
878  
879 SnmpAdminString (entPhysicalSerialNum of chassis).
880  
881 =item EntMfgName (read-only)
882  
883 SnmpAdminString (entPhysicalMfgName of chassis).
884  
885 =item EntModelName (read-only)
886  
887 SnmpAdminString (entPhysicalModelName of chassis).
888  
889 =item DataRetentionPolicy (read-only)
890  
891 Data retention policy for IM Database
892  
893 =item CustomerNameReference (read-only)
894  
895 Customer-supplied device name reference, for linking to an external database.
896  
897 =item EnterpriseID (read-only)
898  
899 The value of sysEnterpriseID.
900  
901 =item DeviceKind (read-only)
902  
903 User-specified device type.
904  
905 =item SysUpTime (read-only)
906  
907 System uptime.
908  
909 =item LastModified (read-only)
910  
911 Timestamp of last modification to this device.
912  
913 =item Parent (read-only)
914  
915 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.
916  
917 =item Acknowledge (read-write)
918  
919 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'.
920  
921 =item AckMessage (read-write)
922  
923 The message associated with the acknowledge state. If Acknowledge is not set and an AckMessage is supplied, Acknowledge will be set to 'Basic'.
924  
925 =item AckExpiration (read-write)
926  
927 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.
928  
929 =item AckTimer (read-only)
930  
931 The time in seconds remaining until the timed acknowledgement expires, if any.
932  
933 =item VertexId (read-only)
934  
935 The Vertex Id of the vertex associated with the device. Matches the VertexId of the corresponding vertex in the vertices table.
936  
937 =item Layer2 (read-only)
938  
939 True if layer2 mapping is enabled for this device.
940  
941 =back
942  
943 =over 3
944  
945 =item header
946  
947 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.
948  
949 =back
950  
951 =over 3
952  
953 =item toTAB
954  
955 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.
956  
957 =back
958  
959 =over 3
960  
961 =item toCSV
962  
963 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.
964  
965 =back
966  
967 =over 3
968  
969 =item toXML
970  
971 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.
972  
973 =back
974  
975 =over 3
976  
977 =item mode
978  
979 Internal method to properly format the data and header for CRUD actions. Typically not used.
980  
981 =back
982  
983 =item $ERROR
984  
985 NEEDS TO BE ADDED
986  
987 This variable will contain detailed error information.
988
989 =back
990  
991 =head1 REQUIREMENTS
992  
993 For this library to work, you need an instance with Intermapper (obviously) or a simulator like L<Net::Intermapper::Mock>.
994  
995 =over 3
996  
997 =item L<Moose>
998  
999 =item L<IO::Socket::SSL>
1000  
1001 =item L<LWP::UserAgent>
1002  
1003 =item L<XML::Simple>
1004  
1005 =item L<MIME::Base64>
1006  
1007 =item L<URI::Escape>
1008  
1009 =back
1010
1011 =head1 BUGS
1012  
1013 None so far
1014  
1015 =head1 SUPPORT
1016  
1017 None so far :)
1018  
1019 =head1 AUTHOR
1020  
1021 Hendrik Van Belleghem
1022 CPAN ID: BEATNIK
1023 hendrik.vanbelleghem@gmail.com
1024  
1025 =head1 COPYRIGHT
1026  
1027 This program is free software licensed under the...
1028  
1029 The General Public License (GPL)
1030 Version 2, June 1991
1031  
1032 The full text of the license can be found in the
1033 LICENSE file included with this module.
1034  
1035  
1036 =head1 SEE ALSO
1037  
1038 L<http://download.intermapper.com/docs/UserGuide/Content/09-Reference/09-05-Advanced_Importing/the_directive_line.htm>
1039 L<http://download.intermapper.com/schema/imserverschema.html>
1040  
1041 =cut
1042  
1043 #################### main pod documentation end ###################
1044  
1045 1 __PACKAGE__->meta->make_immutable();
1046  
1047 1 1;
1048 # The preceding line will help the module return a true value
1049  
« blib/lib/Net/Intermapper/Map.pm ↑ Summary blib/lib/Net/Intermapper.pm »