| 1 | package Net::Intermapper::Map; | ||||||||||||
| 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 | 1 | ▶ | BEGIN { | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 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.04'; | |||||||||||
| 9 | 1 | @ISA = qw(Exporter); | |||||||||||
| 10 | 1 | @EXPORT = qw(); | |||||||||||
| 11 | 1 | @EXPORT_OK = qw(); | |||||||||||
| 12 | 1 | %EXPORT_TAGS = (); | |||||||||||
| 13 | |||||||||||||
| 14 | 1 | @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 | 0 | ▶ | default => sub { ""; }, | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 23 | 1 | ); | |||||||||||
| 24 | |||||||||||||
| 25 | has 'MapName' => ( | ||||||||||||
| 26 | is => 'rw', | ||||||||||||
| 27 | isa => 'Str', | ||||||||||||
| 28 | 0 | ▶ | default => sub { ""; }, | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 29 | 1 | ); | |||||||||||
| 30 | |||||||||||||
| 31 | has 'MapPath' => ( | ||||||||||||
| 32 | is => 'rw', | ||||||||||||
| 33 | isa => 'Str', | ||||||||||||
| 34 | 0 | ▶ | default => sub { "/"; }, | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 35 | 1 | ); | |||||||||||
| 36 | |||||||||||||
| 37 | has 'Status' => ( | ||||||||||||
| 38 | is => 'rw', | ||||||||||||
| 39 | isa => 'Str', | ||||||||||||
| 40 | 0 | ▶ | default => sub { ""; }, | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 41 | 1 | ); | |||||||||||
| 42 | |||||||||||||
| 43 | 1 | has 'DeviceCount' => ( | |||||||||||
| 44 | is => 'ro', | ||||||||||||
| 45 | isa => 'Str', | ||||||||||||
| 46 | ); | ||||||||||||
| 47 | |||||||||||||
| 48 | 1 | has 'NetworkCount' => ( | |||||||||||
| 49 | is => 'ro', | ||||||||||||
| 50 | isa => 'Str', | ||||||||||||
| 51 | ); | ||||||||||||
| 52 | |||||||||||||
| 53 | 1 | has 'InterfaceCount' => ( | |||||||||||
| 54 | is => 'ro', | ||||||||||||
| 55 | isa => 'Str', | ||||||||||||
| 56 | ); | ||||||||||||
| 57 | |||||||||||||
| 58 | 1 | has 'DownCount' => ( | |||||||||||
| 59 | is => 'ro', | ||||||||||||
| 60 | isa => 'Str', | ||||||||||||
| 61 | ); | ||||||||||||
| 62 | |||||||||||||
| 63 | 1 | has 'CriticalCount' => ( | |||||||||||
| 64 | is => 'ro', | ||||||||||||
| 65 | isa => 'Str', | ||||||||||||
| 66 | ); | ||||||||||||
| 67 | |||||||||||||
| 68 | 1 | has 'AlarmCount' => ( | |||||||||||
| 69 | is => 'ro', | ||||||||||||
| 70 | isa => 'Str', | ||||||||||||
| 71 | ); | ||||||||||||
| 72 | |||||||||||||
| 73 | 1 | has 'WarningCount' => ( | |||||||||||
| 74 | is => 'ro', | ||||||||||||
| 75 | isa => 'Str', | ||||||||||||
| 76 | ); | ||||||||||||
| 77 | |||||||||||||
| 78 | 1 | has 'OkayCount' => ( | |||||||||||
| 79 | is => 'ro', | ||||||||||||
| 80 | isa => 'Str', | ||||||||||||
| 81 | ); | ||||||||||||
| 82 | |||||||||||||
| 83 | 1 | has 'DataRetentionPolicy' => ( | |||||||||||
| 84 | is => 'rw', | ||||||||||||
| 85 | isa => 'Str', | ||||||||||||
| 86 | ); | ||||||||||||
| 87 | |||||||||||||
| 88 | 1 | has 'IMID' => ( | |||||||||||
| 89 | is => 'rw', | ||||||||||||
| 90 | isa => 'Str', | ||||||||||||
| 91 | ); | ||||||||||||
| 92 | |||||||||||||
| 93 | has 'Enabled' => ( | ||||||||||||
| 94 | is => 'rw', | ||||||||||||
| 95 | isa => 'Str', | ||||||||||||
| 96 | 0 | ▶ | default => sub { ""; }, | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 97 | 1 | ); | |||||||||||
| 98 | |||||||||||||
| 99 | 1 | 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 | 0 | ▶ | default => sub { "create"; }, | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 109 | 1 | ); | |||||||||||
| 110 | |||||||||||||
| 111 | # No Moose | ||||||||||||
| 112 | |||||||||||||
| 113 | sub toXML | ||||||||||||
| 114 | 0 | ▶ | { my $self = shift; | ||||||||||
|
Subroutine
toXML: not called CC=17 SCAR=57.2
Pod
documented
| |||||||||||||
| 115 | 0 | my $id = $self->Id; | |||||||||||
| 116 | 0 | my $result = ""; | |||||||||||
| 117 | 0 | my $mapid = $self->MapId; | |||||||||||
| 118 | 0 | ▶ | my $mapname = $self->MapName || ""; | ||||||||||
|
Condition0%0/2
$self->MapName || ''
MC/DC0%0/1
$self->MapName || ''
$self->MapName
Truth table0%0/2
A
A= $self->MapName
| |||||||||||||
| 119 | 0 | ▶ | my $mappath = $self->MapPath || ""; | ||||||||||
|
Condition0%0/2
$self->MapPath || ''
MC/DC0%0/1
$self->MapPath || ''
$self->MapPath
Truth table0%0/2
A
A= $self->MapPath
| |||||||||||||
| 120 | 0 | ▶ | my $status = $self->Status || ""; | ||||||||||
|
Condition0%0/2
$self->Status || ''
MC/DC0%0/1
$self->Status || ''
$self->Status
Truth table0%0/2
A
A= $self->Status
| |||||||||||||
| 121 | 0 | ▶ | my $devicecount = $self->DeviceCount || ""; | ||||||||||
|
Condition0%0/2
$self->DeviceCount || ''
MC/DC0%0/1
$self->DeviceCount || ''
$self->DeviceCount
Truth table0%0/2
A
A= $self->DeviceCount
| |||||||||||||
| 122 | 0 | ▶ | my $networkcount = $self->NetworkCount || ""; | ||||||||||
|
Condition0%0/2
$self->NetworkCount || ''
MC/DC0%0/1
$self->NetworkCount || ''
$self->NetworkCount
Truth table0%0/2
A
A= $self->NetworkCount
| |||||||||||||
| 123 | 0 | ▶ | my $interfacecount = $self->InterfaceCount || ""; | ||||||||||
|
Condition0%0/2
$self->InterfaceCount || ''
MC/DC0%0/1
$self->InterfaceCount || ''
$self->InterfaceCount
Truth table0%0/2
A
A= $self->InterfaceCount
| |||||||||||||
| 124 | 0 | ▶ | my $downcount = $self->DownCount || ""; | ||||||||||
|
Condition0%0/2
$self->DownCount || ''
MC/DC0%0/1
$self->DownCount || ''
$self->DownCount
Truth table0%0/2
A
A= $self->DownCount
| |||||||||||||
| 125 | 0 | ▶ | my $criticalcount = $self->CriticalCount || ""; | ||||||||||
|
Condition0%0/2
$self->CriticalCount || ''
MC/DC0%0/1
$self->CriticalCount || ''
$self->CriticalCount
Truth table0%0/2
A
A= $self->CriticalCount
| |||||||||||||
| 126 | 0 | ▶ | my $alarmcount = $self->AlarmCount || ""; | ||||||||||
|
Condition0%0/2
$self->AlarmCount || ''
MC/DC0%0/1
$self->AlarmCount || ''
$self->AlarmCount
Truth table0%0/2
A
A= $self->AlarmCount
| |||||||||||||
| 127 | 0 | ▶ | my $warningcount = $self->WarningCount || ""; | ||||||||||
|
Condition0%0/2
$self->WarningCount || ''
MC/DC0%0/1
$self->WarningCount || ''
$self->WarningCount
Truth table0%0/2
A
A= $self->WarningCount
| |||||||||||||
| 128 | 0 | ▶ | my $okaycount = $self->OkayCount || ""; | ||||||||||
|
Condition0%0/2
$self->OkayCount || ''
MC/DC0%0/1
$self->OkayCount || ''
$self->OkayCount
Truth table0%0/2
A
A= $self->OkayCount
| |||||||||||||
| 129 | 0 | ▶ | my $dataretentionpolicy = $self->DataRetentionPolicy || ""; | ||||||||||
|
Condition0%0/2
$self->DataRetentionPolicy || ''
MC/DC0%0/1
$self->DataRetentionPolicy || ''
$self->DataRetentionPolicy
Truth table0%0/2
A
A= $self->DataRetentionPolicy
| |||||||||||||
| 130 | 0 | ▶ | my $imid = $self->IMID || ""; | ||||||||||
|
Condition0%0/2
$self->IMID || ''
MC/DC0%0/1
$self->IMID || ''
$self->IMID
Truth table0%0/2
A
A= $self->IMID
| |||||||||||||
| 131 | 0 | ▶ | my $enabled = $self->Enabled || ""; | ||||||||||
|
Condition0%0/2
$self->Enabled || ''
MC/DC0%0/1
$self->Enabled || ''
$self->Enabled
Truth table0%0/2
A
A= $self->Enabled
| |||||||||||||
| 132 | 0 | ▶ | my $layer2 = $self->Layer2 || ""; | ||||||||||
|
Condition0%0/2
$self->Layer2 || ''
MC/DC0%0/1
$self->Layer2 || ''
$self->Layer2
Truth table0%0/2
A
A= $self->Layer2
| |||||||||||||
| 133 | 0 | ▶ | if ($id) { $result = " <id>$id</id>\n"; } | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 134 | 0 | return $result; | |||||||||||
| 135 | } | ||||||||||||
| 136 | |||||||||||||
| 137 | sub toCSV | ||||||||||||
| 138 | 0 | ▶ | { my $self = shift; | ||||||||||
|
Subroutine
toCSV: not called CC=19 SCAR=59.4
Pod
documented
| |||||||||||||
| 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 | ▶ | { $attributes{$attribute->name} = $attribute->get_value($self) || ""; | ||||||||||
|
Condition0%0/2
$attribute->get_value($self) || ''
MC/DC0%0/1
$attribute->get_value($self) || ''
$attribute->get_value($self)
Truth table0%0/2
A
A= $attribute->get_value($self)
| |||||||||||||
| 145 | } | ||||||||||||
| 146 | 0 | for my $key (@HEADERS) | |||||||||||
| 147 | 0 | ▶ | { if ($self->mode eq "create") | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 148 | 0 | ▶ | { next if $key eq "MapId"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 149 | 0 | ▶ | next if $key eq "Status"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 150 | 0 | ▶ | next if $key eq "DeviceCount"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 151 | 0 | ▶ | next if $key eq "NetworkCount"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 152 | 0 | ▶ | next if $key eq "InterfaceCount"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 153 | 0 | ▶ | next if $key eq "DownCount"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 154 | 0 | ▶ | next if $key eq "CriticalCount"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 155 | 0 | ▶ | next if $key eq "AlarmCount"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 156 | 0 | ▶ | next if $key eq "WarningCount"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 157 | 0 | ▶ | next if $key eq "OkayCount"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 158 | 0 | ▶ | next if $key eq "DataRetentionPolicy"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 159 | 0 | ▶ | next if $key eq "Enabled"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 160 | 0 | ▶ | next if $key eq "Layer2"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 161 | 0 | ▶ | next if $key eq "IMID"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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 | ▶ | { my $self = shift; | ||||||||||
|
Subroutine
toTAB: not called CC=19 SCAR=59.4
Pod
documented
| |||||||||||||
| 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 | ▶ | { $attributes{$attribute->name} = $attribute->get_value($self) || ""; | ||||||||||
|
Condition0%0/2
$attribute->get_value($self) || ''
MC/DC0%0/1
$attribute->get_value($self) || ''
$attribute->get_value($self)
Truth table0%0/2
A
A= $attribute->get_value($self)
| |||||||||||||
| 178 | } | ||||||||||||
| 179 | 0 | for my $key (@HEADERS) | |||||||||||
| 180 | 0 | ▶ | { if ($self->mode eq "create") | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 181 | 0 | ▶ | { next if $key eq "MapId"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 182 | 0 | ▶ | next if $key eq "Status"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 183 | 0 | ▶ | next if $key eq "DeviceCount"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 184 | 0 | ▶ | next if $key eq "NetworkCount"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 185 | 0 | ▶ | next if $key eq "InterfaceCount"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 186 | 0 | ▶ | next if $key eq "DownCount"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 187 | 0 | ▶ | next if $key eq "CriticalCount"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 188 | 0 | ▶ | next if $key eq "AlarmCount"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 189 | 0 | ▶ | next if $key eq "WarningCount"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 190 | 0 | ▶ | next if $key eq "OkayCount"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 191 | 0 | ▶ | next if $key eq "DataRetentionPolicy"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 192 | 0 | ▶ | next if $key eq "Enabled"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 193 | 0 | ▶ | next if $key eq "Layer2"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 194 | 0 | ▶ | next if $key eq "IMID"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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 | ▶ | { my $self = shift; | ||||||||||
|
Subroutine
header: not called CC=17 SCAR=57.2
Pod
documented
| |||||||||||||
| 206 | 0 | ▶ | my $format = shift || ""; | ||||||||||
|
Condition0%0/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||
| 207 | 0 | my $header = "# format=$format table=maps fields="; | |||||||||||
| 208 | 0 | for my $key (@HEADERS) | |||||||||||
| 209 | 0 | ▶ | { next if $key eq "MapId"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 210 | 0 | ▶ | next if $key eq "Status"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 211 | 0 | ▶ | next if $key eq "DeviceCount"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 212 | 0 | ▶ | next if $key eq "NetworkCount"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 213 | 0 | ▶ | next if $key eq "InterfaceCount"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 214 | 0 | ▶ | next if $key eq "DownCount"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 215 | 0 | ▶ | next if $key eq "CriticalCount"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 216 | 0 | ▶ | next if $key eq "AlarmCount"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 217 | 0 | ▶ | next if $key eq "WarningCount"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 218 | 0 | ▶ | next if $key eq "OkayCount"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 219 | 0 | ▶ | next if $key eq "DataRetentionPolicy"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 220 | 0 | ▶ | next if $key eq "Enabled"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 221 | 0 | ▶ | next if $key eq "Layer2"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 222 | 0 | ▶ | next if $key eq "IMID"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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 | 1 | __PACKAGE__->meta->make_immutable(); | |||||||||||
| 509 | |||||||||||||
| 510 | 1 | 1; | |||||||||||
| 511 | # The preceding line will help the module return a true value | ||||||||||||
| 512 | |||||||||||||