| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::Intermapper::Map; |
|
2
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
28
|
|
|
3
|
1
|
|
|
1
|
|
4
|
use Moose; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
BEGIN { |
|
6
|
1
|
|
|
1
|
|
4406
|
use Exporter (); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
20
|
|
|
7
|
1
|
|
|
1
|
|
3
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS @HEADERS); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
98
|
|
|
8
|
1
|
|
|
1
|
|
2
|
$VERSION = '0.04'; |
|
9
|
1
|
|
|
|
|
14
|
@ISA = qw(Exporter); |
|
10
|
1
|
|
|
|
|
2
|
@EXPORT = qw(); |
|
11
|
1
|
|
|
|
|
2
|
@EXPORT_OK = qw(); |
|
12
|
1
|
|
|
|
|
2
|
%EXPORT_TAGS = (); |
|
13
|
|
|
|
|
|
|
|
|
14
|
1
|
|
|
|
|
948
|
@HEADERS = qw(MapId MapName MapPath Status DeviceCount NetworkCount InterfaceCount DownCount CriticalCount AlarmCount WarningCount OkayCount DataRetentionPolicy IMID Enabled Layer2); |
|
15
|
|
|
|
|
|
|
}; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# MOOSE! |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has 'MapId' => ( |
|
20
|
|
|
|
|
|
|
is => 'rw', |
|
21
|
|
|
|
|
|
|
isa => 'Str', |
|
22
|
|
|
|
|
|
|
default => sub { ""; }, |
|
23
|
|
|
|
|
|
|
); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has 'MapName' => ( |
|
26
|
|
|
|
|
|
|
is => 'rw', |
|
27
|
|
|
|
|
|
|
isa => 'Str', |
|
28
|
|
|
|
|
|
|
default => sub { ""; }, |
|
29
|
|
|
|
|
|
|
); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
has 'MapPath' => ( |
|
32
|
|
|
|
|
|
|
is => 'rw', |
|
33
|
|
|
|
|
|
|
isa => 'Str', |
|
34
|
|
|
|
|
|
|
default => sub { "/"; }, |
|
35
|
|
|
|
|
|
|
); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has 'Status' => ( |
|
38
|
|
|
|
|
|
|
is => 'rw', |
|
39
|
|
|
|
|
|
|
isa => 'Str', |
|
40
|
|
|
|
|
|
|
default => sub { ""; }, |
|
41
|
|
|
|
|
|
|
); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
has 'DeviceCount' => ( |
|
44
|
|
|
|
|
|
|
is => 'ro', |
|
45
|
|
|
|
|
|
|
isa => 'Str', |
|
46
|
|
|
|
|
|
|
); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
has 'NetworkCount' => ( |
|
49
|
|
|
|
|
|
|
is => 'ro', |
|
50
|
|
|
|
|
|
|
isa => 'Str', |
|
51
|
|
|
|
|
|
|
); |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
has 'InterfaceCount' => ( |
|
54
|
|
|
|
|
|
|
is => 'ro', |
|
55
|
|
|
|
|
|
|
isa => 'Str', |
|
56
|
|
|
|
|
|
|
); |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
has 'DownCount' => ( |
|
59
|
|
|
|
|
|
|
is => 'ro', |
|
60
|
|
|
|
|
|
|
isa => 'Str', |
|
61
|
|
|
|
|
|
|
); |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
has 'CriticalCount' => ( |
|
64
|
|
|
|
|
|
|
is => 'ro', |
|
65
|
|
|
|
|
|
|
isa => 'Str', |
|
66
|
|
|
|
|
|
|
); |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
has 'AlarmCount' => ( |
|
69
|
|
|
|
|
|
|
is => 'ro', |
|
70
|
|
|
|
|
|
|
isa => 'Str', |
|
71
|
|
|
|
|
|
|
); |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
has 'WarningCount' => ( |
|
74
|
|
|
|
|
|
|
is => 'ro', |
|
75
|
|
|
|
|
|
|
isa => 'Str', |
|
76
|
|
|
|
|
|
|
); |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
has 'OkayCount' => ( |
|
79
|
|
|
|
|
|
|
is => 'ro', |
|
80
|
|
|
|
|
|
|
isa => 'Str', |
|
81
|
|
|
|
|
|
|
); |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
has 'DataRetentionPolicy' => ( |
|
84
|
|
|
|
|
|
|
is => 'rw', |
|
85
|
|
|
|
|
|
|
isa => 'Str', |
|
86
|
|
|
|
|
|
|
); |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
has 'IMID' => ( |
|
89
|
|
|
|
|
|
|
is => 'rw', |
|
90
|
|
|
|
|
|
|
isa => 'Str', |
|
91
|
|
|
|
|
|
|
); |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
has 'Enabled' => ( |
|
94
|
|
|
|
|
|
|
is => 'rw', |
|
95
|
|
|
|
|
|
|
isa => 'Str', |
|
96
|
|
|
|
|
|
|
default => sub { ""; }, |
|
97
|
|
|
|
|
|
|
); |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
has 'Layer2' => ( |
|
100
|
|
|
|
|
|
|
is => 'rw', |
|
101
|
|
|
|
|
|
|
isa => 'Str', |
|
102
|
|
|
|
|
|
|
); |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# This methode is used for generating only wanted fields.. |
|
105
|
|
|
|
|
|
|
has 'mode' => ( # create, update, delete |
|
106
|
|
|
|
|
|
|
is => 'rw', |
|
107
|
|
|
|
|
|
|
isa => 'Str', |
|
108
|
|
|
|
|
|
|
default => sub { "create"; }, |
|
109
|
|
|
|
|
|
|
); |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# No Moose |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub toXML |
|
114
|
0
|
|
|
0
|
1
|
|
{ my $self = shift; |
|
115
|
0
|
|
|
|
|
|
my $id = $self->Id; |
|
116
|
0
|
|
|
|
|
|
my $result = ""; |
|
117
|
0
|
|
|
|
|
|
my $mapid = $self->MapId; |
|
118
|
0
|
|
0
|
|
|
|
my $mapname = $self->MapName || ""; |
|
119
|
0
|
|
0
|
|
|
|
my $mappath = $self->MapPath || ""; |
|
120
|
0
|
|
0
|
|
|
|
my $status = $self->Status || ""; |
|
121
|
0
|
|
0
|
|
|
|
my $devicecount = $self->DeviceCount || ""; |
|
122
|
0
|
|
0
|
|
|
|
my $networkcount = $self->NetworkCount || ""; |
|
123
|
0
|
|
0
|
|
|
|
my $interfacecount = $self->InterfaceCount || ""; |
|
124
|
0
|
|
0
|
|
|
|
my $downcount = $self->DownCount || ""; |
|
125
|
0
|
|
0
|
|
|
|
my $criticalcount = $self->CriticalCount || ""; |
|
126
|
0
|
|
0
|
|
|
|
my $alarmcount = $self->AlarmCount || ""; |
|
127
|
0
|
|
0
|
|
|
|
my $warningcount = $self->WarningCount || ""; |
|
128
|
0
|
|
0
|
|
|
|
my $okaycount = $self->OkayCount || ""; |
|
129
|
0
|
|
0
|
|
|
|
my $dataretentionpolicy = $self->DataRetentionPolicy || ""; |
|
130
|
0
|
|
0
|
|
|
|
my $imid = $self->IMID || ""; |
|
131
|
0
|
|
0
|
|
|
|
my $enabled = $self->Enabled || ""; |
|
132
|
0
|
|
0
|
|
|
|
my $layer2 = $self->Layer2 || ""; |
|
133
|
0
|
0
|
|
|
|
|
if ($id) { $result = " <id>$id</id>\n"; } |
|
|
0
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
|
return $result; |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub toCSV |
|
138
|
0
|
|
|
0
|
1
|
|
{ my $self = shift; |
|
139
|
0
|
|
|
|
|
|
my $id = $self->MapId; |
|
140
|
0
|
|
|
|
|
|
my $result = ""; |
|
141
|
0
|
|
|
|
|
|
my @attributes = $self->meta->get_all_attributes; |
|
142
|
0
|
|
|
|
|
|
my %attributes = (); |
|
143
|
0
|
|
|
|
|
|
for my $attribute (@attributes) |
|
144
|
0
|
|
0
|
|
|
|
{ $attributes{$attribute->name} = $attribute->get_value($self) || ""; |
|
145
|
|
|
|
|
|
|
} |
|
146
|
0
|
|
|
|
|
|
for my $key (@HEADERS) |
|
147
|
0
|
0
|
|
|
|
|
{ if ($self->mode eq "create") |
|
148
|
0
|
0
|
|
|
|
|
{ next if $key eq "MapId"; |
|
149
|
0
|
0
|
|
|
|
|
next if $key eq "Status"; |
|
150
|
0
|
0
|
|
|
|
|
next if $key eq "DeviceCount"; |
|
151
|
0
|
0
|
|
|
|
|
next if $key eq "NetworkCount"; |
|
152
|
0
|
0
|
|
|
|
|
next if $key eq "InterfaceCount"; |
|
153
|
0
|
0
|
|
|
|
|
next if $key eq "DownCount"; |
|
154
|
0
|
0
|
|
|
|
|
next if $key eq "CriticalCount"; |
|
155
|
0
|
0
|
|
|
|
|
next if $key eq "AlarmCount"; |
|
156
|
0
|
0
|
|
|
|
|
next if $key eq "WarningCount"; |
|
157
|
0
|
0
|
|
|
|
|
next if $key eq "OkayCount"; |
|
158
|
0
|
0
|
|
|
|
|
next if $key eq "DataRetentionPolicy"; |
|
159
|
0
|
0
|
|
|
|
|
next if $key eq "Enabled"; |
|
160
|
0
|
0
|
|
|
|
|
next if $key eq "Layer2"; |
|
161
|
0
|
0
|
|
|
|
|
next if $key eq "IMID"; |
|
162
|
0
|
|
|
|
|
|
$result .= $attributes{$key}.","; } |
|
163
|
|
|
|
|
|
|
} |
|
164
|
0
|
|
|
|
|
|
chop $result; # Remove the comma of the last field |
|
165
|
0
|
|
|
|
|
|
$result =~ s/\s$//g; |
|
166
|
0
|
|
|
|
|
|
$result .= "\r\n"; |
|
167
|
0
|
|
|
|
|
|
return $result; |
|
168
|
|
|
|
|
|
|
} |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub toTAB |
|
171
|
0
|
|
|
0
|
1
|
|
{ my $self = shift; |
|
172
|
0
|
|
|
|
|
|
my $mapid = $self->MapId; |
|
173
|
0
|
|
|
|
|
|
my $result = ""; |
|
174
|
0
|
|
|
|
|
|
my @attributes = $self->meta->get_all_attributes; |
|
175
|
0
|
|
|
|
|
|
my %attributes = (); |
|
176
|
0
|
|
|
|
|
|
for my $attribute (@attributes) |
|
177
|
0
|
|
0
|
|
|
|
{ $attributes{$attribute->name} = $attribute->get_value($self) || ""; |
|
178
|
|
|
|
|
|
|
} |
|
179
|
0
|
|
|
|
|
|
for my $key (@HEADERS) |
|
180
|
0
|
0
|
|
|
|
|
{ if ($self->mode eq "create") |
|
181
|
0
|
0
|
|
|
|
|
{ next if $key eq "MapId"; |
|
182
|
0
|
0
|
|
|
|
|
next if $key eq "Status"; |
|
183
|
0
|
0
|
|
|
|
|
next if $key eq "DeviceCount"; |
|
184
|
0
|
0
|
|
|
|
|
next if $key eq "NetworkCount"; |
|
185
|
0
|
0
|
|
|
|
|
next if $key eq "InterfaceCount"; |
|
186
|
0
|
0
|
|
|
|
|
next if $key eq "DownCount"; |
|
187
|
0
|
0
|
|
|
|
|
next if $key eq "CriticalCount"; |
|
188
|
0
|
0
|
|
|
|
|
next if $key eq "AlarmCount"; |
|
189
|
0
|
0
|
|
|
|
|
next if $key eq "WarningCount"; |
|
190
|
0
|
0
|
|
|
|
|
next if $key eq "OkayCount"; |
|
191
|
0
|
0
|
|
|
|
|
next if $key eq "DataRetentionPolicy"; |
|
192
|
0
|
0
|
|
|
|
|
next if $key eq "Enabled"; |
|
193
|
0
|
0
|
|
|
|
|
next if $key eq "Layer2"; |
|
194
|
0
|
0
|
|
|
|
|
next if $key eq "IMID"; |
|
195
|
0
|
|
|
|
|
|
$result .= $attributes{$key}."\t"; |
|
196
|
|
|
|
|
|
|
} |
|
197
|
|
|
|
|
|
|
} |
|
198
|
0
|
|
|
|
|
|
chop $result; # Remove the comma of the last field |
|
199
|
0
|
|
|
|
|
|
$result =~ s/\s$//g; |
|
200
|
0
|
|
|
|
|
|
$result .= "\r\n"; |
|
201
|
0
|
|
|
|
|
|
return $result; |
|
202
|
|
|
|
|
|
|
} |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
sub header |
|
205
|
0
|
|
|
0
|
1
|
|
{ my $self = shift; |
|
206
|
0
|
|
0
|
|
|
|
my $format = shift || ""; |
|
207
|
0
|
|
|
|
|
|
my $header = "# format=$format table=maps fields="; |
|
208
|
0
|
|
|
|
|
|
for my $key (@HEADERS) |
|
209
|
0
|
0
|
|
|
|
|
{ next if $key eq "MapId"; |
|
210
|
0
|
0
|
|
|
|
|
next if $key eq "Status"; |
|
211
|
0
|
0
|
|
|
|
|
next if $key eq "DeviceCount"; |
|
212
|
0
|
0
|
|
|
|
|
next if $key eq "NetworkCount"; |
|
213
|
0
|
0
|
|
|
|
|
next if $key eq "InterfaceCount"; |
|
214
|
0
|
0
|
|
|
|
|
next if $key eq "DownCount"; |
|
215
|
0
|
0
|
|
|
|
|
next if $key eq "CriticalCount"; |
|
216
|
0
|
0
|
|
|
|
|
next if $key eq "AlarmCount"; |
|
217
|
0
|
0
|
|
|
|
|
next if $key eq "WarningCount"; |
|
218
|
0
|
0
|
|
|
|
|
next if $key eq "OkayCount"; |
|
219
|
0
|
0
|
|
|
|
|
next if $key eq "DataRetentionPolicy"; |
|
220
|
0
|
0
|
|
|
|
|
next if $key eq "Enabled"; |
|
221
|
0
|
0
|
|
|
|
|
next if $key eq "Layer2"; |
|
222
|
0
|
0
|
|
|
|
|
next if $key eq "IMID"; |
|
223
|
0
|
|
|
|
|
|
$header .= $key."\t,"; |
|
224
|
|
|
|
|
|
|
} |
|
225
|
0
|
|
|
|
|
|
chop $header; |
|
226
|
0
|
|
|
|
|
|
$header .= "\r\n"; |
|
227
|
0
|
|
|
|
|
|
return $header; |
|
228
|
|
|
|
|
|
|
} |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=pod |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head1 NAME |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
Net::Intermapper::Map - Interface with the HelpSystems Intermapper HTTP API - Maps |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
use Net::Intermapper; |
|
239
|
|
|
|
|
|
|
my $intermapper = Net::Intermapper->new(hostname=>"10.0.0.1", username=>"admin", password=>"nmsadmin"); |
|
240
|
|
|
|
|
|
|
# Options: |
|
241
|
|
|
|
|
|
|
# hostname - IP or hostname of Intermapper 5.x and 6.x server |
|
242
|
|
|
|
|
|
|
# username - Username of Administrator user |
|
243
|
|
|
|
|
|
|
# password - Password of user |
|
244
|
|
|
|
|
|
|
# ssl - SSL enabled (1 - default) or disabled (0) |
|
245
|
|
|
|
|
|
|
# port - TCP port for querying information. Defaults to 8181 |
|
246
|
|
|
|
|
|
|
# modifyport - TCP port for modifying information. Default to 443 |
|
247
|
|
|
|
|
|
|
# cache - Boolean to enable smart caching or force network queries |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
my %users = $intermapper->users; |
|
250
|
|
|
|
|
|
|
my $users_ref = $intermapper->users; |
|
251
|
|
|
|
|
|
|
# Retrieve all users from Intermapper, Net::Intermapper::User instances |
|
252
|
|
|
|
|
|
|
# Returns hash or hashref, depending on context |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
my %devices = $intermapper->devices; |
|
255
|
|
|
|
|
|
|
my $devices_ref = $intermapper->devices; |
|
256
|
|
|
|
|
|
|
# Retrieve all devices from Intermapper, Net::Intermapper::Device instances |
|
257
|
|
|
|
|
|
|
# Returns hash or hashref, depending on context |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
my %maps = $intermapper->maps; |
|
260
|
|
|
|
|
|
|
my $maps_ref = $intermapper->maps; |
|
261
|
|
|
|
|
|
|
# Retrieve all maps from Intermapper, Net::Intermapper::Map instances |
|
262
|
|
|
|
|
|
|
# Returns hash or hashref, depending on context |
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
my %interfaces = $intermapper->interfaces; |
|
265
|
|
|
|
|
|
|
my $interfaces_ref = $intermapper->interfaces; |
|
266
|
|
|
|
|
|
|
# Retrieve all interfaces from Intermapper, Net::Intermapper::Interface instances |
|
267
|
|
|
|
|
|
|
# Returns hash or hashref, depending on context |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
my %vertices = $intermapper->vertices; |
|
270
|
|
|
|
|
|
|
my $vertices_ref = $intermapper->vertices; |
|
271
|
|
|
|
|
|
|
# Retrieve all vertices from Intermapper, Net::Intermapper::Vertice instances |
|
272
|
|
|
|
|
|
|
# Returns hash or hashref, depending on context |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
my $user = $intermapper->users->{"admin"}; |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
# Each class will generate specific header. These are typically only for internal use but are compliant to the import format Intermapper uses. |
|
277
|
|
|
|
|
|
|
print $user->header; |
|
278
|
|
|
|
|
|
|
print $device->header; |
|
279
|
|
|
|
|
|
|
print $map->header; |
|
280
|
|
|
|
|
|
|
print $interface->header; |
|
281
|
|
|
|
|
|
|
print $vertice->header; |
|
282
|
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
print $user->toTAB; |
|
284
|
|
|
|
|
|
|
print $device->toXML; # This one is broken still! |
|
285
|
|
|
|
|
|
|
print $map->toCSV; |
|
286
|
|
|
|
|
|
|
# Works on ALL subclasses |
|
287
|
|
|
|
|
|
|
# Produce human-readable output of each record in the formats Intermapper supports |
|
288
|
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
my $user = Net::Intermapper::User->new(Name=>"testuser", Password=>"Test12345"); |
|
290
|
|
|
|
|
|
|
my $response = $intermapper->create($user); |
|
291
|
|
|
|
|
|
|
# Create new user |
|
292
|
|
|
|
|
|
|
# Return value is HTTP::Response object |
|
293
|
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
my $device = Net::Intermapper::Device->new(Name=>"testDevice", MapName=>"TestMap", MapPath=>"/TestMap", Address=>"10.0.0.1"); |
|
295
|
|
|
|
|
|
|
my $response = $intermapper->create($device); |
|
296
|
|
|
|
|
|
|
# Create new device |
|
297
|
|
|
|
|
|
|
# Return value is HTTP::Response object |
|
298
|
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
$user->Password("Foobar123"); |
|
300
|
|
|
|
|
|
|
my $response = $intermapper->update($user); |
|
301
|
|
|
|
|
|
|
# Update existing user |
|
302
|
|
|
|
|
|
|
# Return value is HTTP::Response object |
|
303
|
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
my $user = $intermapper->users->{"bob"}; |
|
305
|
|
|
|
|
|
|
my $response = $intermapper->delete($user); |
|
306
|
|
|
|
|
|
|
# Delete existing user |
|
307
|
|
|
|
|
|
|
# Return value is HTTP::Response object |
|
308
|
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
my $device = $intermapper->devices->{"UniqueDeviceID"}; |
|
310
|
|
|
|
|
|
|
my $response = $intermapper->delete($device); |
|
311
|
|
|
|
|
|
|
# Delete existing device |
|
312
|
|
|
|
|
|
|
# Return value is HTTP::Response object |
|
313
|
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
my $users = { "Tom" => $tom_user, "Bob" => $bob_user }; |
|
315
|
|
|
|
|
|
|
$intermapper->users($users); |
|
316
|
|
|
|
|
|
|
# At this point, there is no real reason to do this as update, create and delete work with explicit arguments. |
|
317
|
|
|
|
|
|
|
# But it can be done with users, devices, interfaces, maps and vertices |
|
318
|
|
|
|
|
|
|
# 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). |
|
319
|
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
321
|
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
Net::Intermapper::Device is a perl wrapper around the HelpSystems Intermapper API provided through HTTP/HTTPS for access to map information. |
|
323
|
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
All calls are handled through an instance of the L<Net::Intermapper> class. |
|
325
|
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
use Net::Intermapper; |
|
327
|
|
|
|
|
|
|
my $intermapper = Net::Intermapper->new(hostname => '10.0.0.1', username => 'admin', password => 'nmsadmin'); |
|
328
|
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
=head1 USAGE |
|
330
|
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
=over 3 |
|
332
|
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
=item new |
|
334
|
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
Class constructor. Returns object of Net::Intermapper::Map on succes. Attributes are: |
|
336
|
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
=over 5 |
|
338
|
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
=item MapId (read-only) |
|
340
|
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
A unique, persistant identifier for this map instance. |
|
342
|
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
=item MapName (read-only). This value is used for lookups in the C<users> method in L<Net::Intermapper>. |
|
344
|
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
Name of the map. |
|
346
|
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
=item MapPath (read-only) |
|
348
|
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
Full path of the map, including the name of the map. |
|
350
|
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
=item Status (read-only) |
|
352
|
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
Status of the map (e.g. down, critical, alarm, warning, okay). |
|
354
|
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
=item DeviceCount (read-only) |
|
356
|
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
Number of devices in the map. |
|
358
|
|
|
|
|
|
|
|
|
359
|
|
|
|
|
|
|
=item NetworkCount (read-only) |
|
360
|
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
Number of networks in the map. |
|
362
|
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
=item InterfaceCount (read-only) |
|
364
|
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
Number of interfaces in the map. |
|
366
|
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
=item DownCount (read-only) |
|
368
|
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
Number of devices that are down. |
|
370
|
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
=item CriticalCount (read-only) |
|
372
|
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
Number of devices in critical status. |
|
374
|
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
=item AlarmCount (read-only) |
|
376
|
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
Number of devices in alarm status. |
|
378
|
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
=item WarningCount (read-only) |
|
380
|
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
Number of devices in warning status. |
|
382
|
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
=item OkayCount (read-only) |
|
384
|
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
Number of okay devices. |
|
386
|
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
=item DataRetentionPolicy (read-only) |
|
388
|
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
Database retention policy. |
|
390
|
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
=item IMID (read-only) |
|
392
|
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
Identifier of the map in the IMID format. |
|
394
|
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
=item Enabled (read-only) |
|
396
|
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
True if the map is currently running. |
|
398
|
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
=item Layer2 (read-only) |
|
400
|
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
True if the map is enabled for layer 2 polling. |
|
402
|
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
=back |
|
404
|
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
=over 3 |
|
406
|
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
=item header |
|
408
|
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
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. |
|
410
|
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
=back |
|
412
|
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
=over 3 |
|
414
|
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
=item toTAB |
|
416
|
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
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. |
|
418
|
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
=back |
|
420
|
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
=over 3 |
|
422
|
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
=item toCSV |
|
424
|
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
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. |
|
426
|
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
=back |
|
428
|
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
=over 3 |
|
430
|
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
=item toXML |
|
432
|
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
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. |
|
434
|
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
=back |
|
436
|
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
=over 3 |
|
438
|
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
=item mode |
|
440
|
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
Internal method to properly format the data and header for CRUD actions. Typically not used. |
|
442
|
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
=back |
|
444
|
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
=item $ERROR |
|
446
|
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
NEEDS TO BE ADDED |
|
448
|
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
This variable will contain detailed error information. |
|
450
|
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
=back |
|
452
|
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
=head1 REQUIREMENTS |
|
454
|
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
For this library to work, you need an instance with Intermapper (obviously) or a simulator like L<Net::Intermapper::Mock>. |
|
456
|
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
=over 3 |
|
458
|
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
=item L<Moose> |
|
460
|
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
=item L<IO::Socket::SSL> |
|
462
|
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
=item L<LWP::UserAgent> |
|
464
|
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
=item L<XML::Simple> |
|
466
|
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
=item L<MIME::Base64> |
|
468
|
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
=item L<URI::Escape> |
|
470
|
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
=item L<Text::CSV_XS> |
|
472
|
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
=back |
|
474
|
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
=head1 BUGS |
|
476
|
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
None yet |
|
478
|
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
=head1 SUPPORT |
|
480
|
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
None yet :) |
|
482
|
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
=head1 AUTHOR |
|
484
|
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
Hendrik Van Belleghem |
|
486
|
|
|
|
|
|
|
CPAN ID: BEATNIK |
|
487
|
|
|
|
|
|
|
hendrik.vanbelleghem@gmail.com |
|
488
|
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
490
|
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
This program is free software licensed under the... |
|
492
|
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
The General Public License (GPL) |
|
494
|
|
|
|
|
|
|
Version 2, June 1991 |
|
495
|
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
The full text of the license can be found in the |
|
497
|
|
|
|
|
|
|
LICENSE file included with this module. |
|
498
|
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
501
|
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
L<http://download.intermapper.com/docs/UserGuide/Content/09-Reference/09-05-Advanced_Importing/the_directive_line.htm> |
|
503
|
|
|
|
|
|
|
L<http://download.intermapper.com/schema/imserverschema.html> |
|
504
|
|
|
|
|
|
|
|
|
505
|
|
|
|
|
|
|
=cut |
|
506
|
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
#################### main pod documentation end ################### |
|
508
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(); |
|
509
|
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
1; |
|
511
|
|
|
|
|
|
|
# The preceding line will help the module return a true value |
|
512
|
|
|
|
|
|
|
|