| 1 |
|
| # SNMP::Info::Layer3::Passport |
| 2 |
|
| # |
| 3 |
|
| # Copyright (c) 2016 Eric Miller |
| 4 |
|
| # All rights reserved. |
| 5 |
|
| # |
| 6 |
|
| # Redistribution and use in source and binary forms, with or without |
| 7 |
|
| # modification, are permitted provided that the following conditions are met: |
| 8 |
|
| # |
| 9 |
|
| # * Redistributions of source code must retain the above copyright notice, |
| 10 |
|
| # this list of conditions and the following disclaimer. |
| 11 |
|
| # * Redistributions in binary form must reproduce the above copyright |
| 12 |
|
| # notice, this list of conditions and the following disclaimer in the |
| 13 |
|
| # documentation and/or other materials provided with the distribution. |
| 14 |
|
| # * Neither the name of the University of California, Santa Cruz nor the |
| 15 |
|
| # names of its contributors may be used to endorse or promote products |
| 16 |
|
| # derived from this software without specific prior written permission. |
| 17 |
|
| # |
| 18 |
|
| # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 19 |
|
| # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 20 |
|
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 21 |
|
| # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 22 |
|
| # LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 23 |
|
| # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 24 |
|
| # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 25 |
|
| # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 26 |
|
| # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 27 |
|
| # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 28 |
|
| # POSSIBILITY OF SUCH DAMAGE. |
| 29 |
|
| |
| 30 |
|
| package SNMP::Info::Layer3::Passport; |
| 31 |
|
| |
| 32 |
|
| use warnings; |
| 33 |
|
| use strict; |
| 34 |
|
| use Exporter; |
| 35 |
|
| use SNMP::Info::SONMP; |
| 36 |
|
| use SNMP::Info::RapidCity; |
| 37 |
|
| use SNMP::Info::RapidCityLegacy; |
| 38 |
|
| use SNMP::Info::Layer3; |
| 39 |
|
| |
| 40 |
|
| @SNMP::Info::Layer3::Passport::ISA |
| 41 |
|
| = qw/SNMP::Info::SONMP SNMP::Info::RapidCityLegacy SNMP::Info::RapidCity |
| 42 |
|
| SNMP::Info::Layer3 Exporter/; |
| 43 |
|
| @SNMP::Info::Layer3::Passport::EXPORT_OK = qw//; |
| 44 |
|
| |
| 45 |
|
| our ($VERSION, %GLOBALS, %FUNCS, %MIBS, %MUNGE); |
| 46 |
|
| |
| 47 |
|
| $VERSION = '3.985003'; |
| 48 |
|
| |
| 49 |
|
| %MIBS = ( |
| 50 |
|
| %SNMP::Info::Layer3::MIBS, %SNMP::Info::RapidCity::MIBS, |
| 51 |
|
| %SNMP::Info::RapidCityLegacy::MIBS, %SNMP::Info::SONMP::MIBS, |
| 52 |
|
| ); |
| 53 |
|
| |
| 54 |
|
| %GLOBALS = ( |
| 55 |
|
| %SNMP::Info::Layer3::GLOBALS, %SNMP::Info::RapidCity::GLOBALS, |
| 56 |
|
| %SNMP::Info::RapidCityLegacy::GLOBALS, %SNMP::Info::SONMP::GLOBALS, |
| 57 |
|
| ); |
| 58 |
|
| |
| 59 |
|
| %FUNCS = ( |
| 60 |
|
| %SNMP::Info::Layer3::FUNCS, %SNMP::Info::RapidCity::FUNCS, |
| 61 |
|
| %SNMP::Info::RapidCityLegacy::FUNCS, %SNMP::Info::SONMP::FUNCS, |
| 62 |
|
| ); |
| 63 |
|
| |
| 64 |
|
| %MUNGE = ( |
| 65 |
|
| %SNMP::Info::Layer3::MUNGE, %SNMP::Info::RapidCity::MUNGE, |
| 66 |
|
| %SNMP::Info::RapidCityLegacy::MUNGE, %SNMP::Info::SONMP::MUNGE, |
| 67 |
|
| ); |
| 68 |
|
| |
| 69 |
|
| sub model { |
| 70 |
|
| my $passport = shift; |
| 71 |
|
| my $id = $passport->id(); |
| 72 |
|
| |
| 73 |
|
| unless ( defined $id ) { |
| 74 |
|
| print |
| 75 |
|
| " SNMP::Info::Layer3::Passport::model() - Device does not support sysObjectID\n" |
| 76 |
|
| if $passport->debug(); |
| 77 |
|
| return; |
| 78 |
|
| } |
| 79 |
|
| |
| 80 |
|
| my $model = &SNMP::translateObj($id); |
| 81 |
|
| |
| 82 |
|
| return $id unless defined $model; |
| 83 |
|
| |
| 84 |
|
| $model =~ s/^rc(A)?//i; |
| 85 |
|
| return $model; |
| 86 |
|
| } |
| 87 |
|
| |
| 88 |
|
| sub vendor { |
| 89 |
|
| return 'avaya'; |
| 90 |
|
| } |
| 91 |
|
| |
| 92 |
|
| sub os { |
| 93 |
|
| return 'passport'; |
| 94 |
|
| } |
| 95 |
|
| |
| 96 |
|
| sub os_ver { |
| 97 |
|
| my $passport = shift; |
| 98 |
|
| my $descr = $passport->description(); |
| 99 |
|
| return unless defined $descr; |
| 100 |
|
| |
| 101 |
|
| #ERS / Passport |
| 102 |
|
| if ( $descr =~ m/(\d+\.\d+\.\d+\.\d+)/ ) { |
| 103 |
|
| return $1; |
| 104 |
|
| } |
| 105 |
|
| |
| 106 |
|
| #Accelar |
| 107 |
|
| if ( $descr =~ m/(\d+\.\d+\.\d+)/ ) { |
| 108 |
|
| return $1; |
| 109 |
|
| } |
| 110 |
|
| return; |
| 111 |
|
| } |
| 112 |
|
| |
| 113 |
|
| sub i_index { |
| 114 |
|
| my $passport = shift; |
| 115 |
|
| my $partial = shift; |
| 116 |
|
| |
| 117 |
|
| my $i_index = $passport->orig_i_index($partial); |
| 118 |
|
| my $model = $passport->model(); |
| 119 |
|
| |
| 120 |
|
| my %if_index; |
| 121 |
|
| foreach my $iid ( keys %$i_index ) { |
| 122 |
|
| my $index = $i_index->{$iid}; |
| 123 |
|
| next unless defined $index; |
| 124 |
|
| |
| 125 |
|
| $if_index{$iid} = $index; |
| 126 |
|
| } |
| 127 |
|
| |
| 128 |
|
| # Get VLAN Virtual Router Interfaces |
| 129 |
|
| if (!defined $partial |
| 130 |
|
| || (defined $model |
| 131 |
|
| && ( ( $partial > 2000 && $model =~ /^8[8631]|16|VSP/ ) |
| 132 |
|
| || ( $partial > 256 && $model =~ /^1[012][05]0/ ) ) |
| 133 |
|
| ) |
| 134 |
|
| ) |
| 135 |
|
| { |
| 136 |
|
| |
| 137 |
|
| my $vlan_index = $passport->rc_vlan_if() || {}; |
| 138 |
|
| |
| 139 |
|
| foreach my $vid ( keys %$vlan_index ) { |
| 140 |
|
| my $v_index = $vlan_index->{$vid}; |
| 141 |
|
| next unless defined $v_index; |
| 142 |
|
| next if $v_index == 0; |
| 143 |
|
| next if ( defined $partial and $v_index !~ /^$partial$/ ); |
| 144 |
|
| |
| 145 |
|
| $if_index{$v_index} = $v_index; |
| 146 |
|
| } |
| 147 |
|
| } |
| 148 |
|
| |
| 149 |
|
| if ( defined $model and $model =~ /^8[86]/ ) { |
| 150 |
|
| |
| 151 |
|
| my $cpu_index = $passport->rc_cpu_ifindex($partial) || {}; |
| 152 |
|
| my $virt_ip = $passport->rc_virt_ip(); |
| 153 |
|
| |
| 154 |
|
| # Get CPU Ethernet Interfaces |
| 155 |
|
| foreach my $cid ( keys %$cpu_index ) { |
| 156 |
|
| my $c_index = $cpu_index->{$cid}; |
| 157 |
|
| next unless defined $c_index; |
| 158 |
|
| next if $c_index == 0; |
| 159 |
|
| |
| 160 |
|
| $if_index{$c_index} = $c_index; |
| 161 |
|
| } |
| 162 |
|
| |
| 163 |
|
| # Check for Virtual Mgmt Interface |
| 164 |
|
| unless ( $virt_ip eq '0.0.0.0' ) { |
| 165 |
|
| |
| 166 |
|
| # Make up an index number, 1 is not reserved AFAIK |
| 167 |
|
| $if_index{1} = 1; |
| 168 |
|
| } |
| 169 |
|
| } |
| 170 |
|
| return \%if_index; |
| 171 |
|
| } |
| 172 |
|
| |
| 173 |
|
| sub interfaces { |
| 174 |
|
| my $passport = shift; |
| 175 |
|
| my $partial = shift; |
| 176 |
|
| |
| 177 |
|
| my $i_index = $passport->i_index($partial); |
| 178 |
|
| my $i_descr = $passport->orig_i_description($partial) || {}; |
| 179 |
|
| my $model = $passport->model(); |
| 180 |
|
| my $index_factor = $passport->index_factor(); |
| 181 |
|
| my $port_offset = $passport->port_offset(); |
| 182 |
|
| my $slot_offset = $passport->slot_offset(); |
| 183 |
|
| my $vlan_index = {}; |
| 184 |
|
| my %reverse_vlan; |
| 185 |
|
| my $vlan_id = {}; |
| 186 |
|
| |
| 187 |
|
| if (!defined $partial |
| 188 |
|
| || (defined $model |
| 189 |
|
| && ( ( $partial > 2000 && $model =~ /^8[8631]|16|VSP/ ) |
| 190 |
|
| || ( $partial > 256 && $model =~ /^1[012][05]0/ ) ) |
| 191 |
|
| ) |
| 192 |
|
| ) |
| 193 |
|
| { |
| 194 |
|
| $vlan_index = $passport->rc_vlan_if() || {}; |
| 195 |
|
| %reverse_vlan = reverse %$vlan_index; |
| 196 |
|
| $vlan_id = $passport->rc_vlan_id(); |
| 197 |
|
| } |
| 198 |
|
| |
| 199 |
|
| my %if; |
| 200 |
|
| foreach my $iid ( keys %$i_index ) { |
| 201 |
|
| my $index = $i_index->{$iid}; |
| 202 |
|
| next unless defined $index; |
| 203 |
|
| |
| 204 |
|
| if ( ( $index == 1 ) and ( $model =~ /^8[86]/ ) ) { |
| 205 |
|
| $if{$index} = 'Cpu.Virtual'; |
| 206 |
|
| } |
| 207 |
|
| |
| 208 |
|
| elsif ( ( $iid == 64 ) and ( $model =~ /^VSP[478]/ ) ) { |
| 209 |
|
| $if{$index} = 'Mgmt.1'; |
| 210 |
|
| } |
| 211 |
|
| |
| 212 |
|
| elsif ( ( $index == 192 ) and ( $model =~ /^8[86]03/ ) ) { |
| 213 |
|
| $if{$index} = 'Cpu.3'; |
| 214 |
|
| } |
| 215 |
|
| |
| 216 |
|
| elsif ( ( $index == 320 ) and ( $model =~ /^8[86][10][06]/ ) ) { |
| 217 |
|
| $if{$index} = 'Cpu.5'; |
| 218 |
|
| } |
| 219 |
|
| |
| 220 |
|
| elsif ( ( $index == 384 ) and ( $model =~ /^8[86][10][06]/ ) ) { |
| 221 |
|
| $if{$index} = 'Cpu.6'; |
| 222 |
|
| } |
| 223 |
|
| |
| 224 |
|
| elsif (( $index > 2000 and $model =~ /^8[8631]|16|VSP/ ) |
| 225 |
|
| or ( $index > 256 and $model =~ /^1[012][05]0/ ) ) |
| 226 |
|
| { |
| 227 |
|
| |
| 228 |
|
| my $v_index = $reverse_vlan{$iid}; |
| 229 |
|
| my $v_id = $vlan_id->{$v_index}; |
| 230 |
|
| next unless defined $v_id; |
| 231 |
|
| my $v_port = 'Vlan' . "$v_id"; |
| 232 |
|
| $if{$index} = $v_port; |
| 233 |
|
| } |
| 234 |
|
| |
| 235 |
|
| else { |
| 236 |
|
| if ($model =~ /VSP/ and $i_descr->{$iid} and $i_descr->{$iid} =~ m<Port\s+(\d+(?:/\d+)*)>) { |
| 237 |
|
| my $ps = $1; |
| 238 |
|
| $ps =~ s|/|.|g; |
| 239 |
|
| $if{$iid} = $ps; |
| 240 |
|
| } |
| 241 |
|
| else { |
| 242 |
|
| my $port = ( $index % $index_factor ) + $port_offset; |
| 243 |
|
| my $slot = int( $index / $index_factor ) + $slot_offset; |
| 244 |
|
| |
| 245 |
|
| my $slotport = "$slot.$port"; |
| 246 |
|
| $if{$iid} = $slotport; |
| 247 |
|
| } |
| 248 |
|
| } |
| 249 |
|
| |
| 250 |
|
| } |
| 251 |
|
| |
| 252 |
|
| return \%if; |
| 253 |
|
| } |
| 254 |
|
| |
| 255 |
|
| sub i_mac { |
| 256 |
|
| my $passport = shift; |
| 257 |
|
| my $partial = shift; |
| 258 |
|
| |
| 259 |
|
| my $i_mac = $passport->orig_i_mac($partial) || {}; |
| 260 |
|
| my $model = $passport->model(); |
| 261 |
|
| |
| 262 |
|
| my %if_mac; |
| 263 |
|
| foreach my $iid ( keys %$i_mac ) { |
| 264 |
|
| my $mac = $i_mac->{$iid}; |
| 265 |
|
| next unless defined $mac; |
| 266 |
|
| |
| 267 |
|
| $if_mac{$iid} = $mac; |
| 268 |
|
| } |
| 269 |
|
| |
| 270 |
|
| # Get VLAN Virtual Router Interfaces |
| 271 |
|
| if (!defined $partial |
| 272 |
|
| || (defined $model |
| 273 |
|
| && ( ( $partial > 2000 && $model =~ /^8[8631]|16|VSP/ ) |
| 274 |
|
| || ( $partial > 256 && $model =~ /^1[012][05]0/ ) ) |
| 275 |
|
| ) |
| 276 |
|
| ) |
| 277 |
|
| { |
| 278 |
|
| |
| 279 |
|
| my $vlan_index = $passport->rc_vlan_if() || {}; |
| 280 |
|
| my $vlan_mac = $passport->rc_vlan_mac() || {}; |
| 281 |
|
| |
| 282 |
|
| foreach my $iid ( keys %$vlan_mac ) { |
| 283 |
|
| my $v_mac = $vlan_mac->{$iid}; |
| 284 |
|
| next unless defined $v_mac; |
| 285 |
|
| my $v_id = $vlan_index->{$iid}; |
| 286 |
|
| next unless defined $v_id; |
| 287 |
|
| next if ( defined $partial and $v_id !~ /^$partial$/ ); |
| 288 |
|
| |
| 289 |
|
| $if_mac{$v_id} = $v_mac; |
| 290 |
|
| } |
| 291 |
|
| } |
| 292 |
|
| |
| 293 |
|
| if ( defined $model and $model =~ /^8[86]/ ) { |
| 294 |
|
| |
| 295 |
|
| my $cpu_mac = $passport->rc_cpu_mac($partial) || {}; |
| 296 |
|
| my $virt_ip = $passport->rc_virt_ip() || '0.0.0.0'; |
| 297 |
|
| |
| 298 |
|
| # Get CPU Ethernet Interfaces |
| 299 |
|
| foreach my $iid ( keys %$cpu_mac ) { |
| 300 |
|
| my $mac = $cpu_mac->{$iid}; |
| 301 |
|
| next unless defined $mac; |
| 302 |
|
| |
| 303 |
|
| $if_mac{$iid} = $mac; |
| 304 |
|
| } |
| 305 |
|
| |
| 306 |
|
| # Check for Virtual Mgmt Interface |
| 307 |
|
| unless ( ( $virt_ip eq '0.0.0.0' ) |
| 308 |
|
| or ( defined $partial and $partial ne "1" ) ) |
| 309 |
|
| { |
| 310 |
|
| my $chassis_base_mac = $passport->rc_base_mac(); |
| 311 |
|
| if ( defined $chassis_base_mac ) { |
| 312 |
|
| my @virt_mac = split /:/, $chassis_base_mac; |
| 313 |
|
| $virt_mac[0] = hex( $virt_mac[0] ); |
| 314 |
|
| $virt_mac[1] = hex( $virt_mac[1] ); |
| 315 |
|
| $virt_mac[2] = hex( $virt_mac[2] ); |
| 316 |
|
| $virt_mac[3] = hex( $virt_mac[3] ); |
| 317 |
|
| $virt_mac[4] = hex( $virt_mac[4] ) + 0x03; |
| 318 |
|
| $virt_mac[5] = hex( $virt_mac[5] ) + 0xF8; |
| 319 |
|
| |
| 320 |
|
| my $mac = join( ':', map { sprintf "%02x", $_ } @virt_mac ); |
| 321 |
|
| |
| 322 |
|
| $if_mac{1} = $mac; |
| 323 |
|
| } |
| 324 |
|
| } |
| 325 |
|
| } |
| 326 |
|
| return \%if_mac; |
| 327 |
|
| } |
| 328 |
|
| |
| 329 |
|
| sub i_description { |
| 330 |
|
| my $passport = shift; |
| 331 |
|
| my $partial = shift; |
| 332 |
|
| |
| 333 |
|
| my $i_descr = $passport->orig_i_description($partial) || {}; |
| 334 |
|
| my $model = $passport->model(); |
| 335 |
|
| |
| 336 |
|
| my %descr; |
| 337 |
|
| foreach my $iid ( keys %$i_descr ) { |
| 338 |
|
| my $if_descr = $i_descr->{$iid}; |
| 339 |
|
| next unless defined $if_descr; |
| 340 |
|
| |
| 341 |
|
| $descr{$iid} = $if_descr; |
| 342 |
|
| } |
| 343 |
|
| |
| 344 |
|
| # Get VLAN Virtual Router Interfaces |
| 345 |
|
| if (!defined $partial |
| 346 |
|
| || (defined $model |
| 347 |
|
| && ( ( $partial > 2000 && $model =~ /^8[8631]|16|VSP/ ) |
| 348 |
|
| || ( $partial > 256 && $model =~ /^1[012][05]0/ ) ) |
| 349 |
|
| ) |
| 350 |
|
| ) |
| 351 |
|
| { |
| 352 |
|
| |
| 353 |
|
| my $v_descr = $passport->v_name(); |
| 354 |
|
| my $vlan_index = $passport->rc_vlan_if(); |
| 355 |
|
| |
| 356 |
|
| foreach my $vid ( keys %$v_descr ) { |
| 357 |
|
| my $vl_descr = $v_descr->{$vid}; |
| 358 |
|
| next unless defined $vl_descr; |
| 359 |
|
| my $v_id = $vlan_index->{$vid}; |
| 360 |
|
| next unless defined $v_id; |
| 361 |
|
| next if ( defined $partial and $v_id !~ /^$partial$/ ); |
| 362 |
|
| |
| 363 |
|
| $descr{$v_id} = $vl_descr; |
| 364 |
|
| } |
| 365 |
|
| } |
| 366 |
|
| return \%descr; |
| 367 |
|
| } |
| 368 |
|
| |
| 369 |
|
| sub i_name { |
| 370 |
|
| my $passport = shift; |
| 371 |
|
| my $partial = shift; |
| 372 |
|
| |
| 373 |
|
| my $model = $passport->model(); |
| 374 |
|
| my $i_index = $passport->i_index($partial) || {}; |
| 375 |
|
| my $rc_alias = $passport->rc_alias($partial) || {}; |
| 376 |
|
| my $i_alias = $passport->i_alias($partial) || {}; |
| 377 |
|
| my $i_name2 = $passport->orig_i_name($partial) || {}; |
| 378 |
|
| my $v_name = {}; |
| 379 |
|
| my $vlan_index = {}; |
| 380 |
|
| my %reverse_vlan; |
| 381 |
|
| |
| 382 |
|
| if (!defined $partial |
| 383 |
|
| || (defined $model |
| 384 |
|
| && ( ( $partial > 2000 && $model =~ /^8[8631]|16|VSP/ ) |
| 385 |
|
| || ( $partial > 256 && $model =~ /^1[012][05]0/ ) ) |
| 386 |
|
| ) |
| 387 |
|
| ) |
| 388 |
|
| { |
| 389 |
|
| $v_name = $passport->v_name() || {}; |
| 390 |
|
| $vlan_index = $passport->rc_vlan_if() || {}; |
| 391 |
|
| %reverse_vlan = reverse %$vlan_index; |
| 392 |
|
| } |
| 393 |
|
| |
| 394 |
|
| my %i_name; |
| 395 |
|
| foreach my $iid ( keys %$i_index ) { |
| 396 |
|
| |
| 397 |
|
| if ( ( $iid == 1 ) and ( $model =~ /^8[86]/ ) ) { |
| 398 |
|
| $i_name{$iid} = 'CPU Virtual Management IP'; |
| 399 |
|
| } |
| 400 |
|
| |
| 401 |
|
| elsif ( ( $iid == 64 ) and ( $model =~ /^VSP[478]/ ) ) { |
| 402 |
|
| $i_name{$iid} = 'Mgmt Port'; |
| 403 |
|
| } |
| 404 |
|
| |
| 405 |
|
| elsif ( ( $iid == 192 ) and ( $model =~ /^8[86]03/ ) ) { |
| 406 |
|
| $i_name{$iid} = 'CPU 3 Ethernet Port'; |
| 407 |
|
| } |
| 408 |
|
| |
| 409 |
|
| elsif ( ( $iid == 320 ) and ( $model =~ /^8[86][10][06]/ ) ) { |
| 410 |
|
| $i_name{$iid} = 'CPU 5 Ethernet Port'; |
| 411 |
|
| } |
| 412 |
|
| |
| 413 |
|
| elsif ( ( $iid == 384 ) and ( $model =~ /^8[86][10][06]/ ) ) { |
| 414 |
|
| $i_name{$iid} = 'CPU 6 Ethernet Port'; |
| 415 |
|
| } |
| 416 |
|
| |
| 417 |
|
| elsif ( |
| 418 |
|
| ( $iid > 2000 and defined $model and $model =~ /^8[8631]|16|VSP/ ) |
| 419 |
|
| or ( $iid > 256 |
| 420 |
|
| and defined $model |
| 421 |
|
| and $model =~ /^1[012][05]0/ ) |
| 422 |
|
| ) |
| 423 |
|
| { |
| 424 |
|
| my $vlan_idx = $reverse_vlan{$iid}; |
| 425 |
|
| my $vlan_name = $v_name->{$vlan_idx}; |
| 426 |
|
| next unless defined $vlan_name; |
| 427 |
|
| |
| 428 |
|
| $i_name{$iid} = $vlan_name; |
| 429 |
|
| } |
| 430 |
|
| |
| 431 |
|
| else { |
| 432 |
|
| my $name = $i_name2->{$iid}; |
| 433 |
|
| my $pp_alias = $rc_alias->{$iid}; |
| 434 |
|
| my $std_alias = $i_alias->{$iid}; |
| 435 |
|
| my $alias |
| 436 |
|
| = ( defined $pp_alias and $pp_alias !~ /^\s*$/ ) |
| 437 |
|
| ? $pp_alias |
| 438 |
|
| : $std_alias; |
| 439 |
|
| $i_name{$iid} |
| 440 |
|
| = ( defined $alias and $alias !~ /^\s*$/ ) |
| 441 |
|
| ? $alias |
| 442 |
|
| : $name; |
| 443 |
|
| } |
| 444 |
|
| } |
| 445 |
|
| |
| 446 |
|
| return \%i_name; |
| 447 |
|
| } |
| 448 |
|
| |
| 449 |
|
| sub ip_index { |
| 450 |
|
| my $passport = shift; |
| 451 |
|
| my $partial = shift; |
| 452 |
|
| |
| 453 |
|
| my $model = $passport->model(); |
| 454 |
|
| my $ip_index = $passport->SUPER::ip_index($partial) || {}; |
| 455 |
|
| |
| 456 |
|
| my %ip_index; |
| 457 |
|
| foreach my $ip ( keys %$ip_index ) { |
| 458 |
|
| my $iid = $ip_index->{$ip}; |
| 459 |
|
| next unless defined $iid; |
| 460 |
|
| # Skip VSP default CPU addresses |
| 461 |
|
| next if ($ip =~ /^192\.168\.1\.1/); |
| 462 |
|
| # Skip default CPU addresses |
| 463 |
|
| next if ($ip =~ /^192\.168\.168\.16[89]/); |
| 464 |
|
| |
| 465 |
|
| $ip_index{$ip} = $iid; |
| 466 |
|
| } |
| 467 |
|
| |
| 468 |
|
| # Only 8600 has CPU and Virtual Management IP |
| 469 |
|
| if ( defined $model and $model =~ /^8[86]/ ) { |
| 470 |
|
| |
| 471 |
|
| my $cpu_ip = $passport->rc_cpu_ip($partial) || {}; |
| 472 |
|
| my $virt_ip = $passport->rc_virt_ip($partial); |
| 473 |
|
| |
| 474 |
|
| # Get CPU Ethernet IP |
| 475 |
|
| foreach my $cid ( keys %$cpu_ip ) { |
| 476 |
|
| my $c_ip = $cpu_ip->{$cid}; |
| 477 |
|
| next unless defined $c_ip; |
| 478 |
|
| # Skip default CPU addresses |
| 479 |
|
| next if ($c_ip =~ /192\.168\.168\.16[89]/); |
| 480 |
|
| |
| 481 |
|
| $ip_index{$c_ip} = $cid; |
| 482 |
|
| } |
| 483 |
|
| |
| 484 |
|
| # Get Virtual Mgmt IP |
| 485 |
|
| $ip_index{$virt_ip} = 1 if ( defined $virt_ip ); |
| 486 |
|
| } |
| 487 |
|
| |
| 488 |
|
| return \%ip_index; |
| 489 |
|
| } |
| 490 |
|
| |
| 491 |
|
| sub ip_netmask { |
| 492 |
|
| my $passport = shift; |
| 493 |
|
| my $partial = shift; |
| 494 |
|
| |
| 495 |
|
| my $model = $passport->model(); |
| 496 |
|
| my $ip_mask = $passport->SUPER::ip_netmask($partial) || {}; |
| 497 |
|
| |
| 498 |
|
| my %ip_index; |
| 499 |
|
| foreach my $iid ( keys %$ip_mask ) { |
| 500 |
|
| # Skip VSP default CPU addresses |
| 501 |
|
| next if ($iid =~ /^192\.168\.1\./); |
| 502 |
|
| # Skip default CPU addresses |
| 503 |
|
| next if ($iid =~ /^192\.168\.168\.16[89]/); |
| 504 |
|
| my $mask = $ip_mask->{$iid}; |
| 505 |
|
| next unless defined $mask; |
| 506 |
|
| |
| 507 |
|
| $ip_index{$iid} = $mask; |
| 508 |
|
| } |
| 509 |
|
| |
| 510 |
|
| # Only 8600 has CPU and Virtual Management IP |
| 511 |
|
| if ( defined $model and $model =~ /^8[86]/ ) { |
| 512 |
|
| |
| 513 |
|
| my $cpu_ip = $passport->rc_cpu_ip($partial) || {}; |
| 514 |
|
| my $cpu_mask = $passport->rc_cpu_mask($partial) || {}; |
| 515 |
|
| my $virt_ip = $passport->rc_virt_ip($partial); |
| 516 |
|
| my $virt_mask = $passport->rc_virt_mask($partial) || {}; |
| 517 |
|
| |
| 518 |
|
| # Get CPU Ethernet IP |
| 519 |
|
| foreach my $iid ( keys %$cpu_mask ) { |
| 520 |
|
| my $c_ip = $cpu_ip->{$iid}; |
| 521 |
|
| next unless defined $c_ip; |
| 522 |
|
| # Skip default CPU addresses |
| 523 |
|
| next if ($c_ip =~ /192\.168\.168\.16[89]/); |
| 524 |
|
| my $c_mask = $cpu_mask->{$iid}; |
| 525 |
|
| next unless defined $c_mask; |
| 526 |
|
| |
| 527 |
|
| $ip_index{$c_ip} = $c_mask; |
| 528 |
|
| } |
| 529 |
|
| |
| 530 |
|
| # Get Virtual Mgmt IP |
| 531 |
|
| $ip_index{$virt_ip} = $virt_mask |
| 532 |
|
| if ( defined $virt_mask and defined $virt_ip ); |
| 533 |
|
| } |
| 534 |
|
| |
| 535 |
|
| return \%ip_index; |
| 536 |
|
| } |
| 537 |
|
| |
| 538 |
|
| sub root_ip { |
| 539 |
|
| my $passport = shift; |
| 540 |
|
| my $model = $passport->model(); |
| 541 |
|
| my $rc_ip_addr = $passport->rc_ip_addr(); |
| 542 |
|
| my $rc_ip_type = $passport->rc_ip_type(); |
| 543 |
|
| my $virt_ip = $passport->rc_virt_ip(); |
| 544 |
|
| my $router_ip = $passport->router_ip(); |
| 545 |
|
| my $sonmp_topo_port = $passport->sonmp_topo_port(); |
| 546 |
|
| my $sonmp_topo_ip = $passport->sonmp_topo_ip(); |
| 547 |
|
| |
| 548 |
|
| # Only 8600 and 1600 have CLIP or Management Virtual IP |
| 549 |
|
| if ( defined $model and $model =~ /^8[86]|16|VSP/ ) { |
| 550 |
|
| |
| 551 |
|
| # Return CLIP (CircuitLess IP) |
| 552 |
|
| foreach my $iid ( keys %$rc_ip_type ) { |
| 553 |
|
| my $ip_type = $rc_ip_type->{$iid}; |
| 554 |
|
| next |
| 555 |
|
| unless ( ( defined $ip_type ) |
| 556 |
|
| and ( $ip_type =~ /circuitLess/i ) ); |
| 557 |
|
| my $ip = $rc_ip_addr->{$iid}; |
| 558 |
|
| next unless defined $ip; |
| 559 |
|
| |
| 560 |
|
| return $ip if $passport->snmp_connect_ip($ip); |
| 561 |
|
| } |
| 562 |
|
| |
| 563 |
|
| # Return Management Virtual IP address |
| 564 |
|
| if ( ( defined $virt_ip ) and ( $virt_ip ne '0.0.0.0' ) ) { |
| 565 |
|
| return $virt_ip if $passport->snmp_connect_ip($virt_ip); |
| 566 |
|
| } |
| 567 |
|
| } |
| 568 |
|
| |
| 569 |
|
| # Return OSPF Router ID |
| 570 |
|
| if ( ( defined $router_ip ) and ( $router_ip ne '0.0.0.0' ) ) { |
| 571 |
|
| foreach my $iid ( keys %$rc_ip_addr ) { |
| 572 |
|
| my $ip = $rc_ip_addr->{$iid}; |
| 573 |
|
| next unless $router_ip eq $ip; |
| 574 |
|
| return $router_ip if $passport->snmp_connect_ip($router_ip); |
| 575 |
|
| } |
| 576 |
|
| } |
| 577 |
|
| |
| 578 |
|
| # Otherwise Return SONMP Advertised IP Address |
| 579 |
|
| foreach my $entry ( keys %$sonmp_topo_port ) { |
| 580 |
|
| my $port = $sonmp_topo_port->{$entry}; |
| 581 |
|
| next unless $port == 0; |
| 582 |
|
| my $ip = $sonmp_topo_ip->{$entry}; |
| 583 |
|
| return $ip |
| 584 |
|
| if (( defined $ip ) |
| 585 |
|
| and ( $ip ne '0.0.0.0' ) |
| 586 |
|
| and ( $passport->snmp_connect_ip($ip) ) ); |
| 587 |
|
| } |
| 588 |
|
| return; |
| 589 |
|
| } |
| 590 |
|
| |
| 591 |
|
| # Required for SNMP::Info::SONMP |
| 592 |
|
| sub index_factor { |
| 593 |
|
| my $passport = shift; |
| 594 |
|
| my $model = $passport->model(); |
| 595 |
|
| my $index_factor = 64; |
| 596 |
|
| |
| 597 |
|
| # Older Accelar models use base 16 instead of 64 |
| 598 |
|
| $index_factor = 16 |
| 599 |
|
| if ( defined $model and $model =~ /^1[012][05]0/ ); |
| 600 |
|
| |
| 601 |
|
| return $index_factor; |
| 602 |
|
| } |
| 603 |
|
| |
| 604 |
|
| sub slot_offset { |
| 605 |
|
| my $passport = shift; |
| 606 |
|
| my $model = $passport->model(); |
| 607 |
|
| # Newer VSP 4K and 8K start at an index of 192 ~ slot 3 but really slot 1 |
| 608 |
|
| return -2 |
| 609 |
|
| if ( defined $model and $model =~ /^VSP[478]/ ); |
| 610 |
|
| |
| 611 |
|
| return 0; |
| 612 |
|
| } |
| 613 |
|
| |
| 614 |
|
| sub port_offset { |
| 615 |
|
| return 1; |
| 616 |
|
| } |
| 617 |
|
| |
| 618 |
|
| # Bridge MIB does not map Bridge Port to ifIndex correctly |
| 619 |
|
| sub bp_index { |
| 620 |
|
| my $passport = shift; |
| 621 |
|
| my $partial = shift; |
| 622 |
|
| |
| 623 |
|
| my $if_index = $passport->i_index($partial) || {}; |
| 624 |
|
| |
| 625 |
|
| my %bp_index; |
| 626 |
|
| foreach my $iid ( keys %$if_index ) { |
| 627 |
|
| $bp_index{$iid} = $iid; |
| 628 |
|
| } |
| 629 |
|
| |
| 630 |
|
| # If we have MLT's map them to the designated port |
| 631 |
|
| my $trunks = $passport->rc_mlt_index; |
| 632 |
|
| my $dps = $passport->rc_mlt_dp || {}; |
| 633 |
|
| |
| 634 |
|
| if ( ref {} eq ref $trunks and scalar keys %$trunks ) { |
| 635 |
|
| foreach my $m ( keys %$trunks ) { |
| 636 |
|
| my $m_idx = $trunks->{$m}; |
| 637 |
|
| next unless $m_idx; |
| 638 |
|
| my $i_idx = $dps->{$m} ? $dps->{$m} : $m_idx; |
| 639 |
|
| $bp_index{$m_idx} = $i_idx; |
| 640 |
|
| } |
| 641 |
|
| } |
| 642 |
|
| |
| 643 |
|
| return \%bp_index; |
| 644 |
|
| } |
| 645 |
|
| |
| 646 |
|
| # We have devices which support BRIDGE-MIB, Q-BRIDGE-MIB, and RAPID-CITY |
| 647 |
|
| # exclusively. Use standards-based first and fall back to RAPID-CITY. |
| 648 |
|
| sub fw_mac { |
| 649 |
|
| my $passport = shift; |
| 650 |
|
| my $partial = shift; |
| 651 |
|
| |
| 652 |
|
| my $qb = $passport->SUPER::fw_mac($partial); |
| 653 |
|
| return $qb if (ref {} eq ref $qb and scalar keys %$qb); |
| 654 |
|
| |
| 655 |
|
| my $qb_fw_port = $passport->rcBridgeTpFdbPort($partial); |
| 656 |
|
| my $qb_fw_mac = {}; |
| 657 |
|
| foreach my $idx ( keys %$qb_fw_port ) { |
| 658 |
|
| my ( $fdb_id, $mac ) = _rc_fdbtable_index($idx); |
| 659 |
|
| $qb_fw_mac->{$idx} = $mac; |
| 660 |
|
| } |
| 661 |
|
| return $qb_fw_mac; |
| 662 |
|
| } |
| 663 |
|
| |
| 664 |
|
| sub fw_port { |
| 665 |
|
| my $passport = shift; |
| 666 |
|
| my $partial = shift; |
| 667 |
|
| |
| 668 |
|
| my $qb = $passport->SUPER::fw_port($partial); |
| 669 |
|
| return $qb if (ref {} eq ref $qb and scalar keys %$qb); |
| 670 |
|
| |
| 671 |
|
| return $passport->rcBridgeTpFdbPort($partial); |
| 672 |
|
| } |
| 673 |
|
| |
| 674 |
|
| sub fw_status { |
| 675 |
|
| my $passport = shift; |
| 676 |
|
| my $partial = shift; |
| 677 |
|
| |
| 678 |
|
| my $qb = $passport->SUPER::fw_status($partial); |
| 679 |
|
| return $qb if (ref {} eq ref $qb and scalar keys %$qb); |
| 680 |
|
| |
| 681 |
|
| return $passport->rcBridgeTpFdbStatus($partial); |
| 682 |
|
| } |
| 683 |
|
| |
| 684 |
|
| sub qb_fw_vlan { |
| 685 |
|
| my $passport = shift; |
| 686 |
|
| my $partial = shift; |
| 687 |
|
| |
| 688 |
|
| my $qb = $passport->SUPER::qb_fw_vlan($partial); |
| 689 |
|
| return $qb if (ref {} eq ref $qb and scalar keys %$qb); |
| 690 |
|
| |
| 691 |
|
| my $qb_fw_port = $passport->rcBridgeTpFdbPort($partial); |
| 692 |
|
| my $qb_fw_vlan = {}; |
| 693 |
|
| foreach my $idx ( keys %$qb_fw_port ) { |
| 694 |
|
| my ( $fdb_id, $mac ) = _rc_fdbtable_index($idx); |
| 695 |
|
| $qb_fw_vlan->{$idx} = $fdb_id; |
| 696 |
|
| } |
| 697 |
|
| return $qb_fw_vlan; |
| 698 |
|
| } |
| 699 |
|
| |
| 700 |
|
| # break up the rcBridgeTpFdbEntry INDEX into FDB ID and MAC Address. |
| 701 |
|
| sub _rc_fdbtable_index { |
| 702 |
|
| my $idx = shift; |
| 703 |
|
| my @values = split( /\./, $idx ); |
| 704 |
|
| my $fdb_id = shift(@values); |
| 705 |
|
| return ( $fdb_id, join( ':', map { sprintf "%02x", $_ } @values ) ); |
| 706 |
|
| } |
| 707 |
|
| |
| 708 |
|
| |
| 709 |
|
| # Pseudo ENTITY-MIB methods |
| 710 |
|
| |
| 711 |
|
| sub e_index { |
| 712 |
|
| my $passport = shift; |
| 713 |
|
| |
| 714 |
|
| my $model = $passport->model(); |
| 715 |
|
| my $rc_ps_t = $passport->rc_ps_type() || {}; |
| 716 |
|
| |
| 717 |
|
| # We're going to hack an index: Slot/Mda/Position |
| 718 |
|
| # We're going to put chassis and power supplies in a slot |
| 719 |
|
| # which doesn't exist |
| 720 |
|
| my %rc_e_index; |
| 721 |
|
| |
| 722 |
|
| # Make up a chassis index |
| 723 |
|
| $rc_e_index{1} = 1; |
| 724 |
|
| |
| 725 |
|
| # Power supplies are common, handle them first |
| 726 |
|
| foreach my $idx ( keys %$rc_ps_t ) { |
| 727 |
|
| next unless $idx; |
| 728 |
|
| |
| 729 |
|
| # We should never have 90 slots, they will also |
| 730 |
|
| # sort numerically at the bottom |
| 731 |
|
| my $index = $idx + 90 . "0000"; |
| 732 |
|
| $rc_e_index{$index} = $index; |
| 733 |
|
| } |
| 734 |
|
| |
| 735 |
|
| # Older Accelars use RAPID-CITY::rcCardTable |
| 736 |
|
| if ( defined $model and $model =~ /^1[012][05]0/ ) { |
| 737 |
|
| my $rc_c_t = $passport->rc_c_type() || {}; |
| 738 |
|
| foreach my $idx ( keys %$rc_c_t ) { |
| 739 |
|
| next unless $idx; |
| 740 |
|
| |
| 741 |
|
| my $index = "$idx" . "0000"; |
| 742 |
|
| $rc_e_index{$index} = $index; |
| 743 |
|
| $index++; |
| 744 |
|
| $rc_e_index{$index} = $index; |
| 745 |
|
| } |
| 746 |
|
| } |
| 747 |
|
| |
| 748 |
|
| # All newer models use RAPID-CITY::rc2kCardTable |
| 749 |
|
| else { |
| 750 |
|
| my $rc2_c_t = $passport->rc2k_c_ftype() || {}; |
| 751 |
|
| my $rc2_m_t = $passport->rc2k_mda_type() || {}; |
| 752 |
|
| |
| 753 |
|
| foreach my $idx ( keys %$rc2_c_t ) { |
| 754 |
|
| next unless $idx; |
| 755 |
|
| |
| 756 |
|
| my $index = "$idx" . "0000"; |
| 757 |
|
| for ( 0 .. 2 ) { |
| 758 |
|
| $rc_e_index{$index} = $index; |
| 759 |
|
| $index++; |
| 760 |
|
| } |
| 761 |
|
| } |
| 762 |
|
| foreach my $idx ( keys %$rc2_m_t ) { |
| 763 |
|
| next unless $idx; |
| 764 |
|
| next if $idx == 0; |
| 765 |
|
| |
| 766 |
|
| my ( $slot, $mda ) = split /\./, $idx; |
| 767 |
|
| $mda = sprintf( "%02d", $mda ); |
| 768 |
|
| |
| 769 |
|
| my $index = "$idx" . "$mda" . "00"; |
| 770 |
|
| $rc_e_index{$index} = $index; |
| 771 |
|
| $index++; |
| 772 |
|
| $rc_e_index{$index} = $index; |
| 773 |
|
| } |
| 774 |
|
| } |
| 775 |
|
| return \%rc_e_index; |
| 776 |
|
| } |
| 777 |
|
| |
| 778 |
|
| sub e_class { |
| 779 |
|
| my $passport = shift; |
| 780 |
|
| |
| 781 |
|
| my $rc_e_idx = $passport->e_index() || {}; |
| 782 |
|
| |
| 783 |
|
| my %rc_e_class; |
| 784 |
|
| foreach my $iid ( keys %$rc_e_idx ) { |
| 785 |
|
| if ( $iid == 1 ) { |
| 786 |
|
| $rc_e_class{$iid} = 'chassis'; |
| 787 |
|
| } |
| 788 |
|
| elsif ( $iid =~ /^9(\d)/ and length $iid > 5 ) { |
| 789 |
|
| $rc_e_class{$iid} = 'powerSupply'; |
| 790 |
|
| } |
| 791 |
|
| elsif ( $iid =~ /0000$/ ) { |
| 792 |
|
| $rc_e_class{$iid} = 'container'; |
| 793 |
|
| } |
| 794 |
|
| else { |
| 795 |
|
| $rc_e_class{$iid} = 'module'; |
| 796 |
|
| } |
| 797 |
|
| } |
| 798 |
|
| return \%rc_e_class; |
| 799 |
|
| } |
| 800 |
|
| |
| 801 |
|
| sub e_descr { |
| 802 |
|
| my $passport = shift; |
| 803 |
|
| |
| 804 |
|
| my $model = $passport->model(); |
| 805 |
|
| my $rc_ps = $passport->rc_ps_detail() || {}; |
| 806 |
|
| my $rc_ch = $passport->chassis() || ''; |
| 807 |
|
| $rc_ch =~ s/a//; |
| 808 |
|
| |
| 809 |
|
| my %rc_e_descr; |
| 810 |
|
| |
| 811 |
|
| # Chassis |
| 812 |
|
| $rc_e_descr{1} = $rc_ch; |
| 813 |
|
| |
| 814 |
|
| # Power supplies are common, handle them first |
| 815 |
|
| foreach my $idx ( keys %$rc_ps ) { |
| 816 |
|
| next unless $idx; |
| 817 |
|
| my $ps = $rc_ps->{$idx}; |
| 818 |
|
| next unless $ps; |
| 819 |
|
| my $index = $idx + 90 . "0000"; |
| 820 |
|
| $rc_e_descr{$index} = $ps; |
| 821 |
|
| } |
| 822 |
|
| |
| 823 |
|
| # Older Accelars use RAPID-CITY::rcCardTable |
| 824 |
|
| if ( defined $model and $model =~ /^1[012][05]0/ ) { |
| 825 |
|
| my $rc_c_t = $passport->rc_c_type() || {}; |
| 826 |
|
| foreach my $idx ( keys %$rc_c_t ) { |
| 827 |
|
| next unless $idx; |
| 828 |
|
| my $type = $rc_c_t->{$idx}; |
| 829 |
|
| next unless $type; |
| 830 |
|
| my $index = "$idx" . "0000"; |
| 831 |
|
| $rc_e_descr{$index} = "Slot " . "$idx"; |
| 832 |
|
| $index++; |
| 833 |
|
| $rc_e_descr{$index} = $type; |
| 834 |
|
| } |
| 835 |
|
| } |
| 836 |
|
| |
| 837 |
|
| # All newer models use RAPID-CITY::rc2kCardTable |
| 838 |
|
| else { |
| 839 |
|
| my $rc2_cf = $passport->rc2k_c_fdesc() || {}; |
| 840 |
|
| my $rc2_cb = $passport->rc2k_c_bdesc() || {}; |
| 841 |
|
| my $rc2_m = $passport->rc2k_mda_desc() || {}; |
| 842 |
|
| |
| 843 |
|
| foreach my $idx ( keys %$rc2_cf ) { |
| 844 |
|
| next unless $idx; |
| 845 |
|
| my $cf = $rc2_cf->{$idx}; |
| 846 |
|
| next unless $idx; |
| 847 |
|
| my $cb = $rc2_cb->{$idx}; |
| 848 |
|
| |
| 849 |
|
| my $index = "$idx" . "0000"; |
| 850 |
|
| $rc_e_descr{$index} = "Slot " . "$idx"; |
| 851 |
|
| $index++; |
| 852 |
|
| $rc_e_descr{$index} = $cf; |
| 853 |
|
| $index++; |
| 854 |
|
| $rc_e_descr{$index} = $cb; |
| 855 |
|
| } |
| 856 |
|
| foreach my $idx ( keys %$rc2_m ) { |
| 857 |
|
| next unless $idx; |
| 858 |
|
| my $cm = $rc2_m->{$idx}; |
| 859 |
|
| next unless $cm; |
| 860 |
|
| my ( $slot, $mda ) = split /\./, $idx; |
| 861 |
|
| $mda = sprintf( "%02d", $mda ); |
| 862 |
|
| |
| 863 |
|
| my $index = "$idx" . "$mda" . "00"; |
| 864 |
|
| $rc_e_descr{$index} = $cm; |
| 865 |
|
| } |
| 866 |
|
| } |
| 867 |
|
| return \%rc_e_descr; |
| 868 |
|
| } |
| 869 |
|
| |
| 870 |
|
| sub e_type { |
| 871 |
|
| my $passport = shift; |
| 872 |
|
| |
| 873 |
|
| my $model = $passport->model(); |
| 874 |
|
| my $rc_ps = $passport->rc_ps_type() || {}; |
| 875 |
|
| my $rc_ch = $passport->chassis(); |
| 876 |
|
| |
| 877 |
|
| my %rc_e_type; |
| 878 |
|
| |
| 879 |
|
| # Chassis |
| 880 |
|
| $rc_e_type{1} = $rc_ch; |
| 881 |
|
| |
| 882 |
|
| # Power supplies are common, handle them first |
| 883 |
|
| foreach my $idx ( keys %$rc_ps ) { |
| 884 |
|
| next unless $idx; |
| 885 |
|
| my $ps = $rc_ps->{$idx}; |
| 886 |
|
| next unless $ps; |
| 887 |
|
| my $index = $idx + 90 . "0000"; |
| 888 |
|
| $rc_e_type{$index} = $ps; |
| 889 |
|
| } |
| 890 |
|
| |
| 891 |
|
| # Older Accelars use RAPID-CITY::rcCardTable |
| 892 |
|
| if ( defined $model and $model =~ /^1[012][05]0/ ) { |
| 893 |
|
| my $rc_c_t = $passport->rc_c_type() || {}; |
| 894 |
|
| foreach my $idx ( keys %$rc_c_t ) { |
| 895 |
|
| next unless $idx; |
| 896 |
|
| my $type = $rc_c_t->{$idx}; |
| 897 |
|
| next unless $type; |
| 898 |
|
| my $index = "$idx" . "0000"; |
| 899 |
|
| $rc_e_type{$index} = "zeroDotZero"; |
| 900 |
|
| $index++; |
| 901 |
|
| $rc_e_type{$index} = $type; |
| 902 |
|
| } |
| 903 |
|
| } |
| 904 |
|
| |
| 905 |
|
| # All newer models use RAPID-CITY::rc2kCardTable |
| 906 |
|
| else { |
| 907 |
|
| my $rc2_cf = $passport->rc2k_c_ftype() || {}; |
| 908 |
|
| my $rc2_cb = $passport->rc2k_c_btype() || {}; |
| 909 |
|
| my $rc2_m = $passport->rc2k_mda_type() || {}; |
| 910 |
|
| |
| 911 |
|
| foreach my $idx ( keys %$rc2_cf ) { |
| 912 |
|
| next unless $idx; |
| 913 |
|
| my $cf = $rc2_cf->{$idx}; |
| 914 |
|
| next unless $idx; |
| 915 |
|
| my $cb = $rc2_cb->{$idx}; |
| 916 |
|
| |
| 917 |
|
| my $index = "$idx" . "0000"; |
| 918 |
|
| $rc_e_type{$index} = "zeroDotZero"; |
| 919 |
|
| $index++; |
| 920 |
|
| $rc_e_type{$index} = $cf; |
| 921 |
|
| $index++; |
| 922 |
|
| $rc_e_type{$index} = $cb; |
| 923 |
|
| } |
| 924 |
|
| foreach my $idx ( keys %$rc2_m ) { |
| 925 |
|
| next unless $idx; |
| 926 |
|
| my $cm = $rc2_m->{$idx}; |
| 927 |
|
| next unless $cm; |
| 928 |
|
| my ( $slot, $mda ) = split /\./, $idx; |
| 929 |
|
| $mda = sprintf( "%02d", $mda ); |
| 930 |
|
| |
| 931 |
|
| my $index = "$idx" . "$mda" . "00"; |
| 932 |
|
| $rc_e_type{$index} = $cm; |
| 933 |
|
| } |
| 934 |
|
| } |
| 935 |
|
| return \%rc_e_type; |
| 936 |
|
| } |
| 937 |
|
| |
| 938 |
|
| sub e_name { |
| 939 |
|
| my $passport = shift; |
| 940 |
|
| |
| 941 |
|
| my $model = $passport->model(); |
| 942 |
|
| my $rc_e_idx = $passport->e_index() || {}; |
| 943 |
|
| |
| 944 |
|
| my %rc_e_name; |
| 945 |
|
| foreach my $iid ( keys %$rc_e_idx ) { |
| 946 |
|
| |
| 947 |
|
| if ( $iid == 1 ) { |
| 948 |
|
| $rc_e_name{$iid} = 'Chassis'; |
| 949 |
|
| next; |
| 950 |
|
| } |
| 951 |
|
| |
| 952 |
|
| my $mod = int( substr( $iid, -4, 2 ) ); |
| 953 |
|
| my $slot = substr( $iid, -6, 2 ); |
| 954 |
|
| |
| 955 |
|
| if ( $iid =~ /^9(\d)/ and length $iid > 5 ) { |
| 956 |
|
| $rc_e_name{$iid} = "Power Supply $1"; |
| 957 |
|
| } |
| 958 |
|
| elsif ( $iid =~ /(00){2}$/ ) { |
| 959 |
|
| $rc_e_name{$iid} = "Slot $slot"; |
| 960 |
|
| } |
| 961 |
|
| elsif ( $iid =~ /(00){1}$/ ) { |
| 962 |
|
| $rc_e_name{$iid} = "Card $slot, MDA $mod"; |
| 963 |
|
| } |
| 964 |
|
| elsif ( defined $model |
| 965 |
|
| and $model =~ /^1[012][05]0/ |
| 966 |
|
| and $iid =~ /1$/ ) |
| 967 |
|
| { |
| 968 |
|
| $rc_e_name{$iid} = "Card $slot"; |
| 969 |
|
| } |
| 970 |
|
| elsif ( $iid =~ /1$/ ) { |
| 971 |
|
| $rc_e_name{$iid} = "Card $slot (front)"; |
| 972 |
|
| } |
| 973 |
|
| elsif ( $iid =~ /2$/ ) { |
| 974 |
|
| $rc_e_name{$iid} = "Card $slot (back)"; |
| 975 |
|
| } |
| 976 |
|
| } |
| 977 |
|
| return \%rc_e_name; |
| 978 |
|
| } |
| 979 |
|
| |
| 980 |
|
| sub e_hwver { |
| 981 |
|
| my $passport = shift; |
| 982 |
|
| |
| 983 |
|
| my $model = $passport->model(); |
| 984 |
|
| my $rc_ps = $passport->rc_ps_rev() || {}; |
| 985 |
|
| |
| 986 |
|
| my %rc_e_hwver; |
| 987 |
|
| |
| 988 |
|
| # Chassis |
| 989 |
|
| $rc_e_hwver{1} = $passport->rc_ch_rev(); |
| 990 |
|
| |
| 991 |
|
| # Power supplies are common, handle them first |
| 992 |
|
| foreach my $idx ( keys %$rc_ps ) { |
| 993 |
|
| next unless $idx; |
| 994 |
|
| my $ps = $rc_ps->{$idx}; |
| 995 |
|
| next unless $ps; |
| 996 |
|
| my $index = $idx + 90 . "0000"; |
| 997 |
|
| $rc_e_hwver{$index} = $ps; |
| 998 |
|
| } |
| 999 |
|
| |
| 1000 |
|
| # Older Accelars use RAPID-CITY::rcCardTable |
| 1001 |
|
| if ( defined $model and $model =~ /^1[012][05]0/ ) { |
| 1002 |
|
| my $rc_c_t = $passport->rc_c_rev() || {}; |
| 1003 |
|
| foreach my $idx ( keys %$rc_c_t ) { |
| 1004 |
|
| next unless $idx; |
| 1005 |
|
| my $type = $rc_c_t->{$idx}; |
| 1006 |
|
| next unless $type; |
| 1007 |
|
| my $index = "$idx" . "0001"; |
| 1008 |
|
| $rc_e_hwver{$index} = $type; |
| 1009 |
|
| } |
| 1010 |
|
| } |
| 1011 |
|
| |
| 1012 |
|
| # All newer models use RAPID-CITY::rc2kCardTable |
| 1013 |
|
| else { |
| 1014 |
|
| my $rc2_cf = $passport->rc2k_c_frev() || {}; |
| 1015 |
|
| my $rc2_cb = $passport->rc2k_c_brev() || {}; |
| 1016 |
|
| my $rc2_m = $passport->rc2k_mda_rev() || {}; |
| 1017 |
|
| |
| 1018 |
|
| foreach my $idx ( keys %$rc2_cf ) { |
| 1019 |
|
| next unless $idx; |
| 1020 |
|
| my $cf = $rc2_cf->{$idx}; |
| 1021 |
|
| next unless $idx; |
| 1022 |
|
| my $cb = $rc2_cb->{$idx}; |
| 1023 |
|
| |
| 1024 |
|
| my $index = "$idx" . "0001"; |
| 1025 |
|
| $rc_e_hwver{$index} = $cf; |
| 1026 |
|
| $index++; |
| 1027 |
|
| $rc_e_hwver{$index} = $cb; |
| 1028 |
|
| } |
| 1029 |
|
| foreach my $idx ( keys %$rc2_m ) { |
| 1030 |
|
| next unless $idx; |
| 1031 |
|
| my $cm = $rc2_m->{$idx}; |
| 1032 |
|
| next unless $cm; |
| 1033 |
|
| my ( $slot, $mda ) = split /\./, $idx; |
| 1034 |
|
| $mda = sprintf( "%02d", $mda ); |
| 1035 |
|
| |
| 1036 |
|
| my $index = "$idx" . "$mda" . "00"; |
| 1037 |
|
| $rc_e_hwver{$index} = $cm; |
| 1038 |
|
| } |
| 1039 |
|
| } |
| 1040 |
|
| return \%rc_e_hwver; |
| 1041 |
|
| } |
| 1042 |
|
| |
| 1043 |
|
| sub e_vendor { |
| 1044 |
|
| my $passport = shift; |
| 1045 |
|
| |
| 1046 |
|
| my $rc_e_idx = $passport->e_index() || {}; |
| 1047 |
|
| |
| 1048 |
|
| my %rc_e_vendor; |
| 1049 |
|
| foreach my $iid ( keys %$rc_e_idx ) { |
| 1050 |
|
| $rc_e_vendor{$iid} = 'avaya'; |
| 1051 |
|
| } |
| 1052 |
|
| return \%rc_e_vendor; |
| 1053 |
|
| } |
| 1054 |
|
| |
| 1055 |
|
| sub e_serial { |
| 1056 |
|
| my $passport = shift; |
| 1057 |
|
| |
| 1058 |
|
| my $model = $passport->model(); |
| 1059 |
|
| my $rc_ps = $passport->rc_ps_serial() || {}; |
| 1060 |
|
| |
| 1061 |
|
| my %rc_e_serial; |
| 1062 |
|
| |
| 1063 |
|
| # Chassis |
| 1064 |
|
| $rc_e_serial{1} = $passport->rc_serial(); |
| 1065 |
|
| |
| 1066 |
|
| # Power supplies are common, handle them first |
| 1067 |
|
| foreach my $idx ( keys %$rc_ps ) { |
| 1068 |
|
| next unless $idx; |
| 1069 |
|
| my $ps = $rc_ps->{$idx}; |
| 1070 |
|
| next unless $ps; |
| 1071 |
|
| my $index = $idx + 90 . "0000"; |
| 1072 |
|
| $rc_e_serial{$index} = $ps; |
| 1073 |
|
| } |
| 1074 |
|
| |
| 1075 |
|
| # Older Accelars use RAPID-CITY::rcCardTable |
| 1076 |
|
| if ( defined $model and $model =~ /^1[012][05]0/ ) { |
| 1077 |
|
| my $rc_c_t = $passport->rc_c_serial() || {}; |
| 1078 |
|
| foreach my $idx ( keys %$rc_c_t ) { |
| 1079 |
|
| next unless $idx; |
| 1080 |
|
| my $type = $rc_c_t->{$idx}; |
| 1081 |
|
| next unless $type; |
| 1082 |
|
| my $index = "$idx" . "0001"; |
| 1083 |
|
| $rc_e_serial{$index} = $type; |
| 1084 |
|
| } |
| 1085 |
|
| } |
| 1086 |
|
| |
| 1087 |
|
| # All newer models use RAPID-CITY::rc2kCardTable |
| 1088 |
|
| else { |
| 1089 |
|
| my $rc2_cf = $passport->rc2k_c_fserial() || {}; |
| 1090 |
|
| my $rc2_cb = $passport->rc2k_c_bserial() || {}; |
| 1091 |
|
| my $rc2_m = $passport->rc2k_mda_serial() || {}; |
| 1092 |
|
| |
| 1093 |
|
| foreach my $idx ( keys %$rc2_cf ) { |
| 1094 |
|
| next unless $idx; |
| 1095 |
|
| my $cf = $rc2_cf->{$idx}; |
| 1096 |
|
| next unless $idx; |
| 1097 |
|
| my $cb = $rc2_cb->{$idx}; |
| 1098 |
|
| |
| 1099 |
|
| my $index = "$idx" . "0001"; |
| 1100 |
|
| $rc_e_serial{$index} = $cf; |
| 1101 |
|
| $index++; |
| 1102 |
|
| $rc_e_serial{$index} = $cb; |
| 1103 |
|
| } |
| 1104 |
|
| foreach my $idx ( keys %$rc2_m ) { |
| 1105 |
|
| next unless $idx; |
| 1106 |
|
| my $cm = $rc2_m->{$idx}; |
| 1107 |
|
| next unless $cm; |
| 1108 |
|
| my ( $slot, $mda ) = split /\./, $idx; |
| 1109 |
|
| $mda = sprintf( "%02d", $mda ); |
| 1110 |
|
| |
| 1111 |
|
| my $index = "$idx" . "$mda" . "00"; |
| 1112 |
|
| $rc_e_serial{$index} = $cm; |
| 1113 |
|
| } |
| 1114 |
|
| } |
| 1115 |
|
| return \%rc_e_serial; |
| 1116 |
|
| } |
| 1117 |
|
| |
| 1118 |
|
| sub e_pos { |
| 1119 |
|
| my $passport = shift; |
| 1120 |
|
| |
| 1121 |
|
| my $rc_e_idx = $passport->e_index() || {}; |
| 1122 |
|
| |
| 1123 |
|
| my %rc_e_pos; |
| 1124 |
|
| foreach my $iid ( keys %$rc_e_idx ) { |
| 1125 |
|
| next unless $iid; |
| 1126 |
|
| if ( $iid == 1 ) { |
| 1127 |
|
| $rc_e_pos{$iid} = -1; |
| 1128 |
|
| next; |
| 1129 |
|
| } |
| 1130 |
|
| my $sub = int( substr( $iid, -2, 2 ) ); |
| 1131 |
|
| my $mod = int( substr( $iid, -4, 2 ) ); |
| 1132 |
|
| my $slot = substr( $iid, -6, 2 ); |
| 1133 |
|
| if ( $iid =~ /(00){2}$/ ) { |
| 1134 |
|
| $rc_e_pos{$iid} = $slot; |
| 1135 |
|
| } |
| 1136 |
|
| elsif ( $iid =~ /(00){1}$/ ) { |
| 1137 |
|
| $rc_e_pos{$iid} = $mod * 100; |
| 1138 |
|
| } |
| 1139 |
|
| else { |
| 1140 |
|
| $rc_e_pos{$iid} = $sub; |
| 1141 |
|
| } |
| 1142 |
|
| } |
| 1143 |
|
| return \%rc_e_pos; |
| 1144 |
|
| } |
| 1145 |
|
| |
| 1146 |
|
| sub e_parent { |
| 1147 |
|
| my $passport = shift; |
| 1148 |
|
| |
| 1149 |
|
| my $rc_e_idx = $passport->e_index() || {}; |
| 1150 |
|
| |
| 1151 |
|
| my %rc_e_parent; |
| 1152 |
|
| foreach my $iid ( keys %$rc_e_idx ) { |
| 1153 |
|
| next unless $iid; |
| 1154 |
|
| if ( $iid == 1 ) { |
| 1155 |
|
| $rc_e_parent{$iid} = 0; |
| 1156 |
|
| next; |
| 1157 |
|
| } |
| 1158 |
|
| my $slot = substr( $iid, -6, 2 ); |
| 1159 |
|
| if ( $iid =~ /(00){1,2}$/ ) { |
| 1160 |
|
| $rc_e_parent{$iid} = 1; |
| 1161 |
|
| } |
| 1162 |
|
| else { |
| 1163 |
|
| $rc_e_parent{$iid} = "$slot" . "0000"; |
| 1164 |
|
| } |
| 1165 |
|
| } |
| 1166 |
|
| return \%rc_e_parent; |
| 1167 |
|
| } |
| 1168 |
|
| |
| 1169 |
|
| 1; |
| 1170 |
|
| __END__ |