| 1 | # SNMP::Info::Layer3::Aruba | ||
| 2 | # | ||
| 3 | # Copyright (c) 2013 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::Aruba; | ||
| 31 | |||
| 32 | use strict; | ||
| 33 | use warnings; | ||
| 34 | use Exporter; | ||
| 35 | use SNMP::Info::Layer3; | ||
| 36 | |||
| 37 | @SNMP::Info::Layer3::Aruba::ISA = qw/SNMP::Info::Layer3 Exporter/; | ||
| 38 | @SNMP::Info::Layer3::Aruba::EXPORT_OK = qw//; | ||
| 39 | |||
| 40 | our ($VERSION, %FUNCS, %GLOBALS, %MIBS, %MUNGE); | ||
| 41 | |||
| 42 | $VERSION = '3.985003'; | ||
| 43 | |||
| 44 | %MIBS = ( | ||
| 45 | %SNMP::Info::Layer3::MIBS, | ||
| 46 | 'WLSR-AP-MIB' => 'wlsrHideSSID', | ||
| 47 | 'WLSX-IFEXT-MIB' => 'ifExtVlanName', | ||
| 48 | 'WLSX-POE-MIB' => 'wlsxPseSlotPowerAvailable', | ||
| 49 | 'WLSX-SWITCH-MIB' => 'wlsxHostname', | ||
| 50 | 'WLSX-SYSTEMEXT-MIB' => 'wlsxSysExtSwitchBaseMacaddress', | ||
| 51 | 'WLSX-USER-MIB' => 'nUserCurrentVlan', | ||
| 52 | 'WLSX-WLAN-MIB' => 'wlanAPFQLN', | ||
| 53 | |||
| 54 | #'ALCATEL-IND1-TP-DEVICES' => 'familyOmniAccessWireless', | ||
| 55 | ); | ||
| 56 | |||
| 57 | %GLOBALS = ( | ||
| 58 | %SNMP::Info::Layer3::GLOBALS, | ||
| 59 | 'aruba_serial_old' => 'wlsxSwitchLicenseSerialNumber', | ||
| 60 | 'aruba_serial_new' => 'wlsxSysExtLicenseSerialNumber', | ||
| 61 | 'aruba_model' => 'wlsxModelName', | ||
| 62 | 'mac' => 'wlsxSysExtSwitchBaseMacaddress', | ||
| 63 | ); | ||
| 64 | |||
| 65 | %FUNCS = ( | ||
| 66 | %SNMP::Info::Layer3::FUNCS, | ||
| 67 | |||
| 68 | # WLSR-AP-MIB::wlsrConfigTable | ||
| 69 | 'aruba_ap_ssidbcast' => 'wlsrHideSSID', | ||
| 70 | |||
| 71 | # WLSX-IFEXT-MIB::wlsxIfExtPortTable | ||
| 72 | 'aruba_if_idx' => 'ifExtPortIfIndex', | ||
| 73 | 'aruba_if_mode' => 'ifExtMode', | ||
| 74 | 'aruba_if_pvid' => 'ifExtTrunkNativeVlanId', | ||
| 75 | 'aruba_if_duplex' => 'ifExtPortDuplex', | ||
| 76 | |||
| 77 | # WLSX-IFEXT-MIB::wlsxIfExtVlanMemberTable | ||
| 78 | 'aruba_if_vlan_member' => 'ifExtVlanMemberStatus', | ||
| 79 | |||
| 80 | # WLSX-IFEXT-MIB::::wlsxIfExtVlanTable | ||
| 81 | 'aruba_v_name' => 'ifExtVlanName', | ||
| 82 | |||
| 83 | # Other cd11_ methods are indexed by staPhyAddress, we need to | ||
| 84 | # strip staAccessPointBSSID from the aruba_cd11_ methods. | ||
| 85 | # wlanStaRSSI and staSignalToNoiseRatio don't appear to be reporting | ||
| 86 | # distinct values. | ||
| 87 | # WLSX-SWITCH-MIB::wlsxSwitchStationMgmtTable | ||
| 88 | 'aruba_cd11_sigqual' => 'staSignalToNoiseRatio', | ||
| 89 | 'aruba_cd11_txrate' => 'staTransmitRate', | ||
| 90 | |||
| 91 | # WLSX-SWITCH-MIB::wlsxSwitchStationStatsTable | ||
| 92 | 'aruba_cd11_rxbyte' => 'staRxBytes', | ||
| 93 | 'aruba_cd11_txbyte' => 'staTxBytes', | ||
| 94 | 'aruba_cd11_rxpkt' => 'staRxPackets', | ||
| 95 | 'aruba_cd11_txpkt' => 'staTxPackets', | ||
| 96 | |||
| 97 | # WLSX-SYSTEMEXT-MIB::wlsxSysExtCardTable | ||
| 98 | 'aruba_card_type' => 'sysExtCardType', | ||
| 99 | 'aruba_card_serial' => 'sysExtCardSerialNo', | ||
| 100 | 'aruba_card_hw' => 'sysExtCardHwRevision', | ||
| 101 | 'aruba_card_fpga' => 'sysExtCardFpgaRevision', | ||
| 102 | 'aruba_card_no' => 'sysExtCardAssemblyNo', | ||
| 103 | |||
| 104 | # WLSX-USER-MIB::wlsxUserTable | ||
| 105 | 'aruba_user_vlan' => 'nUserCurrentVlan', | ||
| 106 | 'aruba_user_bssid' => 'nUserApBSSID', | ||
| 107 | 'aruba_user_name' => 'userName', | ||
| 108 | |||
| 109 | # WLSX-WLAN-MIB::wlsxWlanRadioTable | ||
| 110 | 'aruba_apif_ch_num' => 'wlanAPRadioChannel', | ||
| 111 | 'aruba_apif_power' => 'wlanAPRadioTransmitPower', | ||
| 112 | 'aruba_apif_type' => 'wlanAPRadioType', | ||
| 113 | 'aruba_apif_name' => 'wlanAPRadioAPName', | ||
| 114 | |||
| 115 | # WLSX-WLAN-MIB::wlsxWlanAPTable | ||
| 116 | 'aruba_ap_fqln' => 'wlanAPFQLN', | ||
| 117 | 'aruba_ap_status' => 'wlanAPStatus', | ||
| 118 | 'aruba_ap_type' => 'wlanAPModel', | ||
| 119 | 'aruba_ap_serial' => 'wlanAPSerialNumber', | ||
| 120 | 'aruba_ap_model' => 'wlanAPModelName', | ||
| 121 | 'aruba_ap_name' => 'wlanAPName', | ||
| 122 | 'aruba_ap_ip' => 'wlanAPIpAddress', | ||
| 123 | 'aruba_ap_hw_ver' => 'wlanAPHwVersion', | ||
| 124 | 'aruba_ap_sw_ver' => 'wlanAPSwVersion', | ||
| 125 | |||
| 126 | # WLSX-WLAN-MIB::wlsxWlanESSIDVlanPoolTable | ||
| 127 | 'aruba_ssid_vlan' => 'wlanESSIDVlanPoolStatus', | ||
| 128 | |||
| 129 | # WLSX-WLAN-MIB::wlsxWlanAPBssidTable | ||
| 130 | 'aruba_ap_bssid_ssid' => 'wlanAPESSID', | ||
| 131 | |||
| 132 | # We pretend to have the CISCO-DOT11-MIB for signal strengths, etc. | ||
| 133 | # WLSX-WLAN-MIB::wlsxWlanStationTable | ||
| 134 | 'cd11_sigstrength' => 'wlanStaRSSI', | ||
| 135 | 'cd11_ssid' => 'wlanStaAccessPointESSID', | ||
| 136 | 'cd11_uptime' => 'wlanStaUpTime', | ||
| 137 | |||
| 138 | ); | ||
| 139 | |||
| 140 | %MUNGE = ( | ||
| 141 | %SNMP::Info::Layer3::MUNGE, | ||
| 142 | 'aruba_ap_fqln' => \&munge_aruba_fqln, | ||
| 143 | 'aruba_ap_type' => \&SNMP::Info::munge_e_type, | ||
| 144 | 'aruba_card_type' => \&SNMP::Info::munge_e_type, | ||
| 145 | 'aruba_ap_bssid_ssid' => \&SNMP::Info::munge_null, | ||
| 146 | 'aruba_user_bssid' => \&SNMP::Info::munge_mac, | ||
| 147 | 'cd11_ssid' => \&SNMP::Info::munge_null, | ||
| 148 | |||
| 149 | ); | ||
| 150 | |||
| 151 | sub layers { | ||
| 152 | return '00000111'; | ||
| 153 | } | ||
| 154 | |||
| 155 | sub os { | ||
| 156 | my $aruba = shift; | ||
| 157 | my %osmap = ( 'alcatel-lucent' => 'aos-w', ); | ||
| 158 | return $osmap{ $aruba->vendor() } || 'arubaos'; | ||
| 159 | } | ||
| 160 | |||
| 161 | sub vendor { | ||
| 162 | my $aruba = shift; | ||
| 163 | my $id = $aruba->id() || 'undef'; | ||
| 164 | my %oidmap = ( 6486 => 'alcatel-lucent', ); | ||
| 165 | $id = $1 if ( defined($id) && $id =~ /^\.1\.3\.6\.1\.4\.1\.(\d+)/ ); | ||
| 166 | |||
| 167 | if ( defined($id) and exists( $oidmap{$id} ) ) { | ||
| 168 | return $oidmap{$id}; | ||
| 169 | } else { | ||
| 170 | return 'aruba'; | ||
| 171 | } | ||
| 172 | } | ||
| 173 | |||
| 174 | sub os_ver { | ||
| 175 | my $aruba = shift; | ||
| 176 | my $descr = $aruba->description(); | ||
| 177 | return unless defined $descr; | ||
| 178 | |||
| 179 | if ( $descr =~ m/Version\s+(\d+\.\d+\.\d+\.\d+)/ ) { | ||
| 180 | return $1; | ||
| 181 | } | ||
| 182 | |||
| 183 | return; | ||
| 184 | } | ||
| 185 | |||
| 186 | sub model { | ||
| 187 | my $aruba = shift; | ||
| 188 | my $id = $aruba->id(); | ||
| 189 | return unless defined $id; | ||
| 190 | my $model = &SNMP::translateObj($id); | ||
| 191 | return $id unless defined $model; | ||
| 192 | |||
| 193 | return $model; | ||
| 194 | } | ||
| 195 | |||
| 196 | sub serial { | ||
| 197 | my $aruba = shift; | ||
| 198 | |||
| 199 | return $aruba->aruba_serial_old() || $aruba->aruba_serial_new(); | ||
| 200 | } | ||
| 201 | |||
| 202 | # Thin APs do not support ifMIB requirement | ||
| 203 | |||
| 204 | sub i_index { | ||
| 205 | my $aruba = shift; | ||
| 206 | my $partial = shift; | ||
| 207 | |||
| 208 | my $i_index = $aruba->orig_i_index($partial) || {}; | ||
| 209 | my $ap_index = $aruba->aruba_apif_ch_num($partial) || {}; | ||
| 210 | |||
| 211 | my %if_index; | ||
| 212 | foreach my $iid ( keys %$i_index ) { | ||
| 213 | my $index = $i_index->{$iid}; | ||
| 214 | next unless defined $index; | ||
| 215 | |||
| 216 | $if_index{$iid} = $index; | ||
| 217 | } | ||
| 218 | |||
| 219 | # Get Attached APs as Interfaces | ||
| 220 | foreach my $ap_id ( keys %$ap_index ) { | ||
| 221 | |||
| 222 | if ( $ap_id =~ /(\d+\.\d+\.\d+\.\d+\.\d+\.\d+)\.(\d+)/ ) { | ||
| 223 | my $mac = join( ':', | ||
| 224 | map { sprintf( "%02x", $_ ) } split( /\./, $1 ) ); | ||
| 225 | my $radio = $2; | ||
| 226 | next unless ( ( defined $mac ) and ( defined $radio ) ); | ||
| 227 | |||
| 228 | $if_index{$ap_id} = "$mac.$radio"; | ||
| 229 | } | ||
| 230 | } | ||
| 231 | |||
| 232 | return \%if_index; | ||
| 233 | } | ||
| 234 | |||
| 235 | sub interfaces { | ||
| 236 | my $aruba = shift; | ||
| 237 | my $partial = shift; | ||
| 238 | |||
| 239 | my $i_index = $aruba->i_index($partial) || {}; | ||
| 240 | my $i_name = $aruba->orig_i_name($partial) || {}; | ||
| 241 | |||
| 242 | my %if; | ||
| 243 | foreach my $iid ( keys %$i_index ) { | ||
| 244 | my $index = $i_index->{$iid}; | ||
| 245 | next unless defined $index; | ||
| 246 | |||
| 247 | if ( $index =~ /^\d+$/ ) { | ||
| 248 | |||
| 249 | # Replace the Index with the ifName field. | ||
| 250 | my $port = $i_name->{$iid}; | ||
| 251 | next unless defined $port; | ||
| 252 | $if{$iid} = $port; | ||
| 253 | } | ||
| 254 | |||
| 255 | else { | ||
| 256 | $if{$iid} = $index; | ||
| 257 | } | ||
| 258 | } | ||
| 259 | return \%if; | ||
| 260 | } | ||
| 261 | |||
| 262 | sub i_name { | ||
| 263 | my $aruba = shift; | ||
| 264 | my $partial = shift; | ||
| 265 | |||
| 266 | my $i_index = $aruba->i_index($partial) || {}; | ||
| 267 | my $i_name = $aruba->orig_i_name($partial) || {}; | ||
| 268 | my $ap_name = $aruba->aruba_apif_name($partial) || {}; | ||
| 269 | |||
| 270 | my %i_name; | ||
| 271 | foreach my $iid ( keys %$i_index ) { | ||
| 272 | my $index = $i_index->{$iid}; | ||
| 273 | next unless defined $index; | ||
| 274 | |||
| 275 | if ( $index =~ /^\d+$/ ) { | ||
| 276 | my $name = $i_name->{$iid}; | ||
| 277 | next unless defined $name; | ||
| 278 | $i_name{$iid} = $name; | ||
| 279 | } | ||
| 280 | |||
| 281 | elsif ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) { | ||
| 282 | my $name = $ap_name->{$iid}; | ||
| 283 | next unless defined $name; | ||
| 284 | $i_name{$iid} = $name; | ||
| 285 | } | ||
| 286 | |||
| 287 | else { | ||
| 288 | $i_name{$iid} = $index; | ||
| 289 | } | ||
| 290 | } | ||
| 291 | return \%i_name; | ||
| 292 | } | ||
| 293 | |||
| 294 | sub i_description { | ||
| 295 | my $aruba = shift; | ||
| 296 | my $partial = shift; | ||
| 297 | |||
| 298 | my $i_descr = $aruba->orig_i_description($partial) || {}; | ||
| 299 | my $ap_index = $aruba->aruba_apif_ch_num($partial) || {}; | ||
| 300 | my $ap_loc = $aruba->aruba_ap_fqln($partial) || {}; | ||
| 301 | |||
| 302 | my %descr; | ||
| 303 | foreach my $iid ( keys %$i_descr ) { | ||
| 304 | my $descr = $i_descr->{$iid}; | ||
| 305 | next unless defined $descr; | ||
| 306 | $descr{$iid} = $descr; | ||
| 307 | } | ||
| 308 | |||
| 309 | foreach my $iid ( keys %$ap_index ) { | ||
| 310 | my @parts = split( /\./, $iid ); | ||
| 311 | my $idx = join( ".", @parts[ 0 .. 5 ] ); | ||
| 312 | my $loc = $ap_loc->{$idx}; | ||
| 313 | next unless defined $loc; | ||
| 314 | |||
| 315 | $descr{$iid} = $loc; | ||
| 316 | } | ||
| 317 | |||
| 318 | return \%descr; | ||
| 319 | } | ||
| 320 | |||
| 321 | sub i_type { | ||
| 322 | my $aruba = shift; | ||
| 323 | my $partial = shift; | ||
| 324 | |||
| 325 | my $i_type = $aruba->orig_i_type($partial) || {}; | ||
| 326 | my $apif_type = $aruba->aruba_apif_type($partial) || {}; | ||
| 327 | |||
| 328 | my %i_type; | ||
| 329 | foreach my $iid ( keys %$i_type ) { | ||
| 330 | my $type = $i_type->{$iid}; | ||
| 331 | next unless defined $type; | ||
| 332 | $i_type{$iid} = $type; | ||
| 333 | } | ||
| 334 | |||
| 335 | foreach my $iid ( keys %$apif_type ) { | ||
| 336 | my $type = $apif_type->{$iid}; | ||
| 337 | next unless defined $type; | ||
| 338 | |||
| 339 | $i_type{$iid} = $type; | ||
| 340 | } | ||
| 341 | |||
| 342 | return \%i_type; | ||
| 343 | } | ||
| 344 | |||
| 345 | sub i_up { | ||
| 346 | my $aruba = shift; | ||
| 347 | my $partial = shift; | ||
| 348 | |||
| 349 | my $i_up = $aruba->orig_i_up($partial) || {}; | ||
| 350 | my $ap_index = $aruba->aruba_apif_ch_num($partial) || {}; | ||
| 351 | my $ap_up = $aruba->aruba_ap_status($partial) || {}; | ||
| 352 | |||
| 353 | my %i_up; | ||
| 354 | foreach my $iid ( keys %$i_up ) { | ||
| 355 | my $status = $i_up->{$iid}; | ||
| 356 | next unless defined $status; | ||
| 357 | $i_up{$iid} = $status; | ||
| 358 | } | ||
| 359 | |||
| 360 | foreach my $iid ( keys %$ap_index ) { | ||
| 361 | my @parts = split( /\./, $iid ); | ||
| 362 | my $idx = join( ".", @parts[ 0 .. 5 ] ); | ||
| 363 | my $status = $ap_up->{$idx}; | ||
| 364 | next unless defined $status; | ||
| 365 | |||
| 366 | $i_up{$iid} = $status; | ||
| 367 | } | ||
| 368 | |||
| 369 | return \%i_up; | ||
| 370 | } | ||
| 371 | |||
| 372 | # Fake this for AP's since admin up if operationally up | ||
| 373 | sub i_up_admin { | ||
| 374 | my $aruba = shift; | ||
| 375 | my $partial = shift; | ||
| 376 | |||
| 377 | my $i_up = $aruba->orig_i_up_admin($partial) || {}; | ||
| 378 | my $ap_index = $aruba->aruba_apif_ch_num($partial) || {}; | ||
| 379 | my $ap_up = $aruba->aruba_ap_status($partial) || {}; | ||
| 380 | |||
| 381 | my %i_up; | ||
| 382 | foreach my $iid ( keys %$i_up ) { | ||
| 383 | my $status = $i_up->{$iid}; | ||
| 384 | next unless defined $status; | ||
| 385 | $i_up{$iid} = $status; | ||
| 386 | } | ||
| 387 | |||
| 388 | foreach my $iid ( keys %$ap_index ) { | ||
| 389 | my @parts = split( /\./, $iid ); | ||
| 390 | my $idx = join( ".", @parts[ 0 .. 5 ] ); | ||
| 391 | my $status = $ap_up->{$idx}; | ||
| 392 | next unless defined $status; | ||
| 393 | |||
| 394 | $i_up{$iid} = $status; | ||
| 395 | } | ||
| 396 | |||
| 397 | return \%i_up; | ||
| 398 | } | ||
| 399 | |||
| 400 | sub i_mac { | ||
| 401 | my $aruba = shift; | ||
| 402 | my $partial = shift; | ||
| 403 | |||
| 404 | my $i_index = $aruba->i_index($partial) || {}; | ||
| 405 | my $i_mac = $aruba->orig_i_mac($partial) || {}; | ||
| 406 | |||
| 407 | my %i_mac; | ||
| 408 | foreach my $iid ( keys %$i_index ) { | ||
| 409 | my $index = $i_index->{$iid}; | ||
| 410 | next unless defined $index; | ||
| 411 | |||
| 412 | if ( $index =~ /^\d+$/ ) { | ||
| 413 | my $mac = $i_mac->{$iid}; | ||
| 414 | next unless defined $mac; | ||
| 415 | $i_mac{$iid} = $mac; | ||
| 416 | } | ||
| 417 | elsif ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) { | ||
| 418 | $index =~ s/\.\d+$//; | ||
| 419 | next unless defined $index; | ||
| 420 | $i_mac{$iid} = $index; | ||
| 421 | } | ||
| 422 | } | ||
| 423 | return \%i_mac; | ||
| 424 | } | ||
| 425 | |||
| 426 | sub i_duplex { | ||
| 427 | my $aruba = shift; | ||
| 428 | my $partial = shift; | ||
| 429 | |||
| 430 | my $index = $aruba->aruba_if_idx(); | ||
| 431 | |||
| 432 | if ($partial) { | ||
| 433 | my %r_index = reverse %$index; | ||
| 434 | $partial = $r_index{$partial}; | ||
| 435 | } | ||
| 436 | |||
| 437 | my $ap_duplex = $aruba->aruba_if_duplex($partial) || {}; | ||
| 438 | my %i_duplex; | ||
| 439 | |||
| 440 | foreach my $if ( keys %$ap_duplex ) { | ||
| 441 | my $duplex = $ap_duplex->{$if}; | ||
| 442 | next unless defined $duplex; | ||
| 443 | my $ifindex = $index->{$if}; | ||
| 444 | next unless defined $ifindex; | ||
| 445 | |||
| 446 | $duplex = 'half' if $duplex =~ /half/i; | ||
| 447 | $duplex = 'full' if $duplex =~ /full/i; | ||
| 448 | $duplex = 'auto' if $duplex =~ /auto/i; | ||
| 449 | $i_duplex{$ifindex} = $duplex; | ||
| 450 | } | ||
| 451 | return \%i_duplex; | ||
| 452 | } | ||
| 453 | |||
| 454 | sub v_index { | ||
| 455 | my $aruba = shift; | ||
| 456 | my $partial = shift; | ||
| 457 | |||
| 458 | return $aruba->SUPER::v_index($partial) | ||
| 459 | if keys %{ $aruba->SUPER::v_index($partial) }; | ||
| 460 | |||
| 461 | my $v_name = $aruba->v_name($partial); | ||
| 462 | my %v_index; | ||
| 463 | foreach my $idx ( keys %$v_name ) { | ||
| 464 | $v_index{$idx} = $idx; | ||
| 465 | } | ||
| 466 | return \%v_index; | ||
| 467 | } | ||
| 468 | |||
| 469 | sub v_name { | ||
| 470 | my $aruba = shift; | ||
| 471 | my $partial = shift; | ||
| 472 | |||
| 473 | return $aruba->SUPER::v_name() || $aruba->aruba_v_name(); | ||
| 474 | } | ||
| 475 | |||
| 476 | sub i_vlan { | ||
| 477 | my $aruba = shift; | ||
| 478 | my $partial = shift; | ||
| 479 | |||
| 480 | return $aruba->SUPER::i_vlan($partial) | ||
| 481 | if keys %{ $aruba->SUPER::i_vlan($partial) }; | ||
| 482 | |||
| 483 | # If we don't have Q-BRIDGE-MIB, we're a wireless controller | ||
| 484 | my $index = $aruba->aruba_if_idx(); | ||
| 485 | |||
| 486 | if ($partial) { | ||
| 487 | my %r_index = reverse %$index; | ||
| 488 | $partial = $r_index{$partial}; | ||
| 489 | } | ||
| 490 | |||
| 491 | my $i_pvid = $aruba->aruba_if_pvid($partial) || {}; | ||
| 492 | my %i_vlan; | ||
| 493 | |||
| 494 | foreach my $port ( keys %$i_pvid ) { | ||
| 495 | my $vlan = $i_pvid->{$port}; | ||
| 496 | my $ifindex = $index->{$port}; | ||
| 497 | next unless defined $ifindex; | ||
| 498 | |||
| 499 | $i_vlan{$ifindex} = $vlan; | ||
| 500 | } | ||
| 501 | |||
| 502 | return \%i_vlan; | ||
| 503 | } | ||
| 504 | |||
| 505 | sub i_vlan_membership { | ||
| 506 | my $aruba = shift; | ||
| 507 | my $partial = shift; | ||
| 508 | |||
| 509 | return $aruba->SUPER::i_vlan_membership($partial) | ||
| 510 | if keys %{ $aruba->SUPER::i_vlan_membership($partial) }; | ||
| 511 | |||
| 512 | # If we don't have Q-BRIDGE-MIB, we're a wireless controller | ||
| 513 | my $essid_ssid = $aruba->aruba_ap_bssid_ssid(); | ||
| 514 | my $ssid_vlans = $aruba->aruba_ssid_vlan(); | ||
| 515 | my $if_vlans = $aruba->aruba_if_vlan_member(); | ||
| 516 | |||
| 517 | my %vlan_essid; | ||
| 518 | |||
| 519 | # Create a hash of vlan and textual ssid | ||
| 520 | # Possible to have more than one vlan per ssid | ||
| 521 | foreach my $oid ( keys %$ssid_vlans ) { | ||
| 522 | my @parts = split( /\./, $oid ); | ||
| 523 | my $ssidlen = shift(@parts); | ||
| 524 | my $ssid = pack( "C*", splice( @parts, 0, $ssidlen ) ); | ||
| 525 | |||
| 526 | # Remove any control chars | ||
| 527 | $ssid =~ s/[[:cntrl:]]//g; | ||
| 528 | my $vlan = shift(@parts); | ||
| 529 | |||
| 530 | $vlan_essid{$vlan} = $ssid; | ||
| 531 | } | ||
| 532 | |||
| 533 | my $i_vlan_membership = {}; | ||
| 534 | |||
| 535 | # Handle physical ports first | ||
| 536 | foreach my $oid ( keys %$if_vlans ) { | ||
| 537 | my @parts = split( /\./, $oid ); | ||
| 538 | my $vlan = shift(@parts); | ||
| 539 | my $ifindex = shift(@parts); | ||
| 540 | push( @{ $i_vlan_membership->{$ifindex} }, $vlan ); | ||
| 541 | } | ||
| 542 | |||
| 543 | foreach my $oid ( keys %$essid_ssid ) { | ||
| 544 | my $ssid = $essid_ssid->{$oid}; | ||
| 545 | my @parts = split( /\./, $oid ); | ||
| 546 | my $idx = join( ".", @parts[ 0 .. 6 ] ); | ||
| 547 | |||
| 548 | my @vlans = grep { $vlan_essid{$_} eq $ssid } keys %vlan_essid; | ||
| 549 | foreach my $vlan (@vlans) { | ||
| 550 | push( @{ $i_vlan_membership->{$idx} }, $vlan ); | ||
| 551 | } | ||
| 552 | } | ||
| 553 | return $i_vlan_membership; | ||
| 554 | } | ||
| 555 | |||
| 556 | sub i_vlan_membership_untagged { | ||
| 557 | my $aruba = shift; | ||
| 558 | my $partial = shift; | ||
| 559 | |||
| 560 | return $aruba->SUPER::i_vlan_membership_untagged($partial) | ||
| 561 | if keys %{ $aruba->SUPER::i_vlan_membership_untagged($partial) }; | ||
| 562 | |||
| 563 | # If we don't have Q-BRIDGE-MIB, we're a wireless controller | ||
| 564 | # It is unclear if native VLAN is transmitted untagged | ||
| 565 | # This assumes Cisco-like behavior on trunks that native VLAN is | ||
| 566 | # transmitted untagged, if this needs to be changed we will need to | ||
| 567 | # consider ifExtMode rather than just using i_vlan | ||
| 568 | my $if_membership = $aruba->i_vlan_membership(); | ||
| 569 | my $if_ = $aruba->i_vlan(); | ||
| 570 | my $if_mode = $aruba->aruba_if_mode(); | ||
| 571 | |||
| 572 | my $vlans = $aruba->i_vlan($partial); | ||
| 573 | my $i_vlan_membership = {}; | ||
| 574 | foreach my $port (keys %$vlans) { | ||
| 575 | my $vlan = $vlans->{$port}; | ||
| 576 | push( @{ $i_vlan_membership->{$port} }, $vlan ); | ||
| 577 | } | ||
| 578 | |||
| 579 | return $i_vlan_membership; | ||
| 580 | } | ||
| 581 | |||
| 582 | sub i_80211channel { | ||
| 583 | my $aruba = shift; | ||
| 584 | my $partial = shift; | ||
| 585 | |||
| 586 | return $aruba->aruba_apif_ch_num($partial); | ||
| 587 | } | ||
| 588 | |||
| 589 | sub dot11_cur_tx_pwr_mw { | ||
| 590 | my $aruba = shift; | ||
| 591 | my $partial = shift; | ||
| 592 | |||
| 593 | return $aruba->aruba_apif_power($partial); | ||
| 594 | } | ||
| 595 | |||
| 596 | sub i_ssidlist { | ||
| 597 | my $aruba = shift; | ||
| 598 | my $partial = shift; | ||
| 599 | |||
| 600 | my $essid_ssid = $aruba->aruba_ap_bssid_ssid($partial) || {}; | ||
| 601 | |||
| 602 | my %i_ssidlist; | ||
| 603 | |||
| 604 | foreach my $oid ( keys %$essid_ssid ) { | ||
| 605 | my $ssid = $essid_ssid->{$oid}; | ||
| 606 | my @parts = split( /\./, $oid ); | ||
| 607 | |||
| 608 | # Give the SSID a numeric value based upon tail of BSSID | ||
| 609 | my $id = pop(@parts); | ||
| 610 | |||
| 611 | # Get i_index | ||
| 612 | my $iid = join( ".", @parts[ 0 .. 6 ] ); | ||
| 613 | |||
| 614 | $i_ssidlist{"$iid.$id"} = $ssid; | ||
| 615 | } | ||
| 616 | |||
| 617 | return \%i_ssidlist; | ||
| 618 | } | ||
| 619 | |||
| 620 | sub i_ssidbcast { | ||
| 621 | my $aruba = shift; | ||
| 622 | my $partial = shift; | ||
| 623 | |||
| 624 | my $essid_ssid = $aruba->aruba_ap_bssid_ssid($partial) || {}; | ||
| 625 | my $ap_bc = $aruba->aruba_ap_ssidbcast($partial) || {}; | ||
| 626 | |||
| 627 | my %i_bc; | ||
| 628 | foreach my $oid ( keys %$essid_ssid ) { | ||
| 629 | my @parts = split( /\./, $oid ); | ||
| 630 | |||
| 631 | # Give the SSID a numeric value based upon tail of BSSID | ||
| 632 | my $id = $parts[-1]; | ||
| 633 | my $iid = join( ".", splice( @parts, 0, 7 ) ); | ||
| 634 | my $bssid = join( ':', @parts ); | ||
| 635 | |||
| 636 | my $bc = $ap_bc->{$bssid}; | ||
| 637 | next unless defined $bc; | ||
| 638 | $bc = ( $bc ? 0 : 1 ); | ||
| 639 | $i_bc{"$iid.$id"} = $bc; | ||
| 640 | } | ||
| 641 | |||
| 642 | return \%i_bc; | ||
| 643 | } | ||
| 644 | |||
| 645 | sub i_ssidmac { | ||
| 646 | my $aruba = shift; | ||
| 647 | my $partial = shift; | ||
| 648 | |||
| 649 | my $essid_ssid = $aruba->aruba_ap_bssid_ssid($partial) || {}; | ||
| 650 | |||
| 651 | my %i_ssidmac; | ||
| 652 | |||
| 653 | foreach my $oid ( keys %$essid_ssid ) { | ||
| 654 | my @parts = split( /\./, $oid ); | ||
| 655 | |||
| 656 | # Give the SSID a numeric value based upon tail of BSSID | ||
| 657 | my $id = $parts[-1]; | ||
| 658 | my $iid = join( ".", splice( @parts, 0, 7 ) ); | ||
| 659 | my $bssid = join( ':', map { sprintf( "%02x", $_ ) } @parts ); | ||
| 660 | |||
| 661 | $i_ssidmac{"$iid.$id"} = $bssid; | ||
| 662 | } | ||
| 663 | |||
| 664 | return \%i_ssidmac; | ||
| 665 | } | ||
| 666 | |||
| 667 | # Wireless switches do not support the standard Bridge MIB | ||
| 668 | # Wired switches currently (AOS 7.2.0.0) do, but it seems only for | ||
| 669 | # dot1q ports or access ports that are 'untrusted' ? | ||
| 670 | sub bp_index { | ||
| 671 | my $aruba = shift; | ||
| 672 | my $partial = shift; | ||
| 673 | |||
| 674 | my $i_index = $aruba->ifExtPortIfIndex($partial) || {}; | ||
| 675 | my $essid_ssid = $aruba->aruba_ap_bssid_ssid($partial) || {}; | ||
| 676 | |||
| 677 | # Collect standard bp_index first | ||
| 678 | my $wired_bp_index = $aruba->SUPER::bp_index($partial) || {}; | ||
| 679 | my %bp_index; | ||
| 680 | my %offset; | ||
| 681 | |||
| 682 | foreach my $iid ( keys %$wired_bp_index ) { | ||
| 683 | my $index = $wired_bp_index->{$iid}; | ||
| 684 | my $delta = $iid - $index; | ||
| 685 | |||
| 686 | $offset{$delta}++; | ||
| 687 | $bp_index{$iid} = $index; | ||
| 688 | } | ||
| 689 | |||
| 690 | # If the offset between dot1dBasePortIfIndex and ifIndex is consistent | ||
| 691 | # add potentially missing mappings | ||
| 692 | if ( keys %offset == 1 ) { | ||
| 693 | foreach my $iid ( keys %$i_index ) { | ||
| 694 | my $index = $i_index->{$iid}; | ||
| 695 | next unless defined $index; | ||
| 696 | |||
| 697 | # Only augment bp_index, don't overwrite any existing mappings | ||
| 698 | my $iid = (keys %offset)[0] + $index; | ||
| 699 | next if exists $bp_index{$iid}; | ||
| 700 | |||
| 701 | $bp_index{$iid} = $index; | ||
| 702 | } | ||
| 703 | } | ||
| 704 | |||
| 705 | # Get Attached APs as Interfaces | ||
| 706 | foreach my $oid ( keys %$essid_ssid ) { | ||
| 707 | my @parts = split( /\./, $oid ); | ||
| 708 | my $iid = join( ".", splice( @parts, 0, 7 ) ); | ||
| 709 | my $bssid = join( '.', @parts ); | ||
| 710 | |||
| 711 | $bp_index{$bssid} = $iid; | ||
| 712 | } | ||
| 713 | return \%bp_index; | ||
| 714 | } | ||
| 715 | |||
| 716 | sub fw_port { | ||
| 717 | my $aruba = shift; | ||
| 718 | my $partial = shift; | ||
| 719 | |||
| 720 | my $fw_idx = $aruba->aruba_user_bssid($partial) || {}; | ||
| 721 | |||
| 722 | my $wired_fw_port = $aruba->SUPER::qb_fw_port($partial) || {}; | ||
| 723 | my %fw_port = %$wired_fw_port; | ||
| 724 | |||
| 725 | foreach my $idx ( keys %$fw_idx ) { | ||
| 726 | my $port = $fw_idx->{$idx}; | ||
| 727 | next unless $port; | ||
| 728 | my $iid = join( '.', map { hex($_) } split( ':', $port ) ); | ||
| 729 | |||
| 730 | $fw_port{$idx} = $iid; | ||
| 731 | } | ||
| 732 | |||
| 733 | return \%fw_port; | ||
| 734 | } | ||
| 735 | |||
| 736 | sub fw_mac { | ||
| 737 | my $aruba = shift; | ||
| 738 | my $partial = shift; | ||
| 739 | |||
| 740 | my $fw_idx = $aruba->aruba_user_bssid($partial) || {}; | ||
| 741 | |||
| 742 | my $wired_fw_mac = $aruba->SUPER::qb_fw_mac($partial) || {}; | ||
| 743 | my %fw_mac = %$wired_fw_mac; | ||
| 744 | |||
| 745 | foreach my $idx ( keys %$fw_idx ) { | ||
| 746 | my @parts = split( /\./, $idx ); | ||
| 747 | my $mac = join( ':', map { sprintf( "%02x", $_ ) } @parts[ 0 .. 5 ] ); | ||
| 748 | |||
| 749 | $fw_mac{$idx} = $mac; | ||
| 750 | } | ||
| 751 | return \%fw_mac; | ||
| 752 | } | ||
| 753 | |||
| 754 | sub qb_fw_vlan { | ||
| 755 | my $aruba = shift; | ||
| 756 | my $partial = shift; | ||
| 757 | |||
| 758 | my $vlans = $aruba->aruba_user_vlan($partial) || {}; | ||
| 759 | |||
| 760 | my $wired_fw_vlan = $aruba->SUPER::qb_fw_vlan($partial) || {}; | ||
| 761 | my %fw_vlan = %$wired_fw_vlan; | ||
| 762 | |||
| 763 | foreach my $idx ( keys %$vlans ) { | ||
| 764 | my $vlan = $vlans->{$idx}; | ||
| 765 | next unless $vlan; | ||
| 766 | |||
| 767 | $fw_vlan{$idx} = $vlan; | ||
| 768 | } | ||
| 769 | return \%fw_vlan; | ||
| 770 | } | ||
| 771 | |||
| 772 | sub cd11_mac { | ||
| 773 | my $aruba = shift; | ||
| 774 | my $cd11_sigstrength = $aruba->cd11_sigstrength(); | ||
| 775 | |||
| 776 | my $ret = {}; | ||
| 777 | foreach my $idx ( keys %$cd11_sigstrength ) { | ||
| 778 | my $mac = join( ":", map { sprintf "%02x", $_ } split /\./, $idx ); | ||
| 779 | $ret->{$idx} = $mac; | ||
| 780 | } | ||
| 781 | return $ret; | ||
| 782 | } | ||
| 783 | |||
| 784 | sub cd11_sigqual { | ||
| 785 | my $aruba = shift; | ||
| 786 | my $cd11_sigqual = $aruba->aruba_cd11_sigqual(); | ||
| 787 | |||
| 788 | my $ret = {}; | ||
| 789 | foreach my $idx ( keys %$cd11_sigqual ) { | ||
| 790 | my $value = $cd11_sigqual->{$idx}; | ||
| 791 | $idx =~ s/(.\d+){6}$//; | ||
| 792 | |||
| 793 | $ret->{$idx} = $value; | ||
| 794 | } | ||
| 795 | return $ret; | ||
| 796 | } | ||
| 797 | |||
| 798 | sub cd11_txrate { | ||
| 799 | my $aruba = shift; | ||
| 800 | my $cd11_txrate = $aruba->aruba_cd11_txrate(); | ||
| 801 | |||
| 802 | my $ret = {}; | ||
| 803 | foreach my $idx ( keys %$cd11_txrate ) { | ||
| 804 | my $value = $cd11_txrate->{$idx}; | ||
| 805 | my @rates; | ||
| 806 | if ( $value =~ /(\d+)Mbps/ ) { | ||
| 807 | push @rates, $1; | ||
| 808 | } | ||
| 809 | $idx =~ s/(.\d+){6}$//; | ||
| 810 | |||
| 811 | $ret->{$idx} = \@rates; | ||
| 812 | } | ||
| 813 | return $ret; | ||
| 814 | } | ||
| 815 | |||
| 816 | sub cd11_rxbyte { | ||
| 817 | my $aruba = shift; | ||
| 818 | my $cd11_rxbyte = $aruba->aruba_cd11_rxbyte(); | ||
| 819 | |||
| 820 | my $ret = {}; | ||
| 821 | foreach my $idx ( keys %$cd11_rxbyte ) { | ||
| 822 | my $value = $cd11_rxbyte->{$idx}; | ||
| 823 | $idx =~ s/(.\d+){6}$//; | ||
| 824 | |||
| 825 | $ret->{$idx} = $value; | ||
| 826 | } | ||
| 827 | return $ret; | ||
| 828 | } | ||
| 829 | |||
| 830 | sub cd11_txbyte { | ||
| 831 | my $aruba = shift; | ||
| 832 | my $cd11_txbyte = $aruba->aruba_cd11_txbyte(); | ||
| 833 | |||
| 834 | my $ret = {}; | ||
| 835 | foreach my $idx ( keys %$cd11_txbyte ) { | ||
| 836 | my $value = $cd11_txbyte->{$idx}; | ||
| 837 | $idx =~ s/(.\d+){6}$//; | ||
| 838 | |||
| 839 | $ret->{$idx} = $value; | ||
| 840 | } | ||
| 841 | return $ret; | ||
| 842 | } | ||
| 843 | |||
| 844 | sub cd11_rxpkt { | ||
| 845 | my $aruba = shift; | ||
| 846 | my $cd11_rxpkt = $aruba->aruba_cd11_rxpkt(); | ||
| 847 | |||
| 848 | my $ret = {}; | ||
| 849 | foreach my $idx ( keys %$cd11_rxpkt ) { | ||
| 850 | my $value = $cd11_rxpkt->{$idx}; | ||
| 851 | $idx =~ s/(.\d+){6}$//; | ||
| 852 | |||
| 853 | $ret->{$idx} = $value; | ||
| 854 | } | ||
| 855 | return $ret; | ||
| 856 | } | ||
| 857 | |||
| 858 | sub cd11_txpkt { | ||
| 859 | my $aruba = shift; | ||
| 860 | my $cd11_txpkt = $aruba->aruba_cd11_txpkt(); | ||
| 861 | |||
| 862 | my $ret = {}; | ||
| 863 | foreach my $idx ( keys %$cd11_txpkt ) { | ||
| 864 | my $value = $cd11_txpkt->{$idx}; | ||
| 865 | $idx =~ s/(.\d+){6}$//; | ||
| 866 | |||
| 867 | $ret->{$idx} = $value; | ||
| 868 | } | ||
| 869 | return $ret; | ||
| 870 | } | ||
| 871 | |||
| 872 | # Pseudo ENTITY-MIB methods | ||
| 873 | |||
| 874 | sub e_index { | ||
| 875 | my $aruba = shift; | ||
| 876 | |||
| 877 | my $ap_model = $aruba->aruba_ap_model() || {}; | ||
| 878 | my $ap_cards = $aruba->aruba_card_serial() || {}; | ||
| 879 | my %e_index; | ||
| 880 | |||
| 881 | # Chassis | ||
| 882 | $e_index{0} = 1; | ||
| 883 | |||
| 884 | # Cards | ||
| 885 | foreach my $idx ( keys %$ap_cards ) { | ||
| 886 | $e_index{$idx} = $idx + 1; | ||
| 887 | } | ||
| 888 | |||
| 889 | # We're going to hack an index to capture APs | ||
| 890 | foreach my $idx ( keys %$ap_model ) { | ||
| 891 | |||
| 892 | # Create the integer index by joining the last three octets of the MAC. | ||
| 893 | # Hopefully, this will be unique since the manufacturer should be | ||
| 894 | # limited to Aruba. We can't use the entire MAC since | ||
| 895 | # we would exceed the integer size limit. | ||
| 896 | if ( $idx =~ /(\d+\.\d+\.\d+)$/ ) { | ||
| 897 | my $index = int( | ||
| 898 | join( '', map { sprintf "%03d", $_ } split /\./, $1 ) ); | ||
| 899 | $e_index{$idx} = $index; | ||
| 900 | } | ||
| 901 | } | ||
| 902 | return \%e_index; | ||
| 903 | } | ||
| 904 | |||
| 905 | sub e_class { | ||
| 906 | my $aruba = shift; | ||
| 907 | |||
| 908 | my $e_idx = $aruba->e_index() || {}; | ||
| 909 | |||
| 910 | my %e_class; | ||
| 911 | foreach my $iid ( keys %$e_idx ) { | ||
| 912 | if ( $iid eq 0 ) { | ||
| 913 | $e_class{$iid} = 'chassis'; | ||
| 914 | } | ||
| 915 | elsif ( $iid =~ /^\d+$/ ) { | ||
| 916 | $e_class{$iid} = 'module'; | ||
| 917 | } | ||
| 918 | |||
| 919 | # This isn't a valid PhysicalClass, but we're hacking this anyway | ||
| 920 | else { | ||
| 921 | $e_class{$iid} = 'ap'; | ||
| 922 | } | ||
| 923 | } | ||
| 924 | return \%e_class; | ||
| 925 | } | ||
| 926 | |||
| 927 | sub e_name { | ||
| 928 | my $aruba = shift; | ||
| 929 | |||
| 930 | my $e_idx = $aruba->e_index() || {}; | ||
| 931 | |||
| 932 | my %e_name; | ||
| 933 | foreach my $iid ( keys %$e_idx ) { | ||
| 934 | if ( $iid eq 0 ) { | ||
| 935 | $e_name{$iid} = 'WLAN Controller'; | ||
| 936 | } | ||
| 937 | elsif ( $iid =~ /^\d+$/ ) { | ||
| 938 | $e_name{$iid} = "Card $iid"; | ||
| 939 | } | ||
| 940 | else { | ||
| 941 | |||
| 942 | # APs | ||
| 943 | $e_name{$iid} = 'AP'; | ||
| 944 | } | ||
| 945 | } | ||
| 946 | return \%e_name; | ||
| 947 | } | ||
| 948 | |||
| 949 | sub e_descr { | ||
| 950 | my $aruba = shift; | ||
| 951 | |||
| 952 | my $ap_model = $aruba->aruba_ap_model() || {}; | ||
| 953 | my $ap_name = $aruba->aruba_ap_name() || {}; | ||
| 954 | my $ap_loc = $aruba->aruba_ap_fqln() || {}; | ||
| 955 | my $card_type = $aruba->aruba_card_type() || {}; | ||
| 956 | my $card_assy = $aruba->aruba_card_no() || {}; | ||
| 957 | |||
| 958 | my %e_descr; | ||
| 959 | |||
| 960 | # Chassis | ||
| 961 | $e_descr{0} = $aruba->aruba_model(); | ||
| 962 | |||
| 963 | #Cards | ||
| 964 | foreach my $iid ( keys %$card_type ) { | ||
| 965 | my $card = $card_type->{$iid}; | ||
| 966 | next unless defined $card; | ||
| 967 | my $assy = $card_assy->{$iid} || 'unknown'; | ||
| 968 | |||
| 969 | $e_descr{$iid} = "$card Assembly: $assy"; | ||
| 970 | } | ||
| 971 | |||
| 972 | # APs | ||
| 973 | foreach my $iid ( keys %$ap_name ) { | ||
| 974 | my $name = $ap_name->{$iid}; | ||
| 975 | next unless defined $name; | ||
| 976 | my $model = $ap_model->{$iid} || 'AP'; | ||
| 977 | my $loc = $ap_loc->{$iid} || 'unknown'; | ||
| 978 | |||
| 979 | $e_descr{$iid} = "$model: $name ($loc)"; | ||
| 980 | } | ||
| 981 | return \%e_descr; | ||
| 982 | } | ||
| 983 | |||
| 984 | sub e_model { | ||
| 985 | my $aruba = shift; | ||
| 986 | |||
| 987 | my $ap_model = $aruba->aruba_ap_model() || {}; | ||
| 988 | my $card_model = $aruba->aruba_card_type() || {}; | ||
| 989 | |||
| 990 | my %e_model; | ||
| 991 | |||
| 992 | # Chassis | ||
| 993 | $e_model{0} = $aruba->aruba_model(); | ||
| 994 | |||
| 995 | #Cards | ||
| 996 | foreach my $iid ( keys %$card_model ) { | ||
| 997 | my $card = $card_model->{$iid}; | ||
| 998 | next unless defined $card; | ||
| 999 | |||
| 1000 | $e_model{$iid} = $card; | ||
| 1001 | } | ||
| 1002 | |||
| 1003 | # APs | ||
| 1004 | foreach my $iid ( keys %$ap_model ) { | ||
| 1005 | my $model = $ap_model->{$iid}; | ||
| 1006 | next unless defined $model; | ||
| 1007 | |||
| 1008 | $e_model{$iid} = $model; | ||
| 1009 | } | ||
| 1010 | return \%e_model; | ||
| 1011 | } | ||
| 1012 | |||
| 1013 | sub e_type { | ||
| 1014 | my $aruba = shift; | ||
| 1015 | |||
| 1016 | return $aruba->aruba_ap_type() || {}; | ||
| 1017 | } | ||
| 1018 | |||
| 1019 | sub e_hwver { | ||
| 1020 | my $aruba = shift; | ||
| 1021 | |||
| 1022 | my $ap_hw = $aruba->aruba_card_hw() || {}; | ||
| 1023 | my $ap_fpga = $aruba->aruba_card_fpga() || {}; | ||
| 1024 | my $ap_hw_ver = $aruba->aruba_ap_hw_ver() || {}; | ||
| 1025 | |||
| 1026 | my %e_hwver; | ||
| 1027 | |||
| 1028 | # Cards | ||
| 1029 | foreach my $iid ( keys %$ap_hw ) { | ||
| 1030 | my $hw = $ap_hw->{$iid}; | ||
| 1031 | next unless defined $hw; | ||
| 1032 | my $fpga = $ap_fpga->{$iid} || 'unknown'; | ||
| 1033 | |||
| 1034 | $e_hwver{$iid} = "$hw $fpga"; | ||
| 1035 | } | ||
| 1036 | |||
| 1037 | # APs | ||
| 1038 | foreach my $idx ( keys %$ap_hw_ver ) { | ||
| 1039 | my $hw_ver = $ap_hw_ver->{$idx}; | ||
| 1040 | next unless defined $hw_ver; | ||
| 1041 | |||
| 1042 | $e_hwver{$idx} = "$hw_ver"; | ||
| 1043 | } | ||
| 1044 | |||
| 1045 | return \%e_hwver; | ||
| 1046 | } | ||
| 1047 | |||
| 1048 | sub e_swver { | ||
| 1049 | my $aruba = shift; | ||
| 1050 | |||
| 1051 | my $ap_sw_ver = $aruba->aruba_ap_hw_ver() || {}; | ||
| 1052 | |||
| 1053 | my %e_swver; | ||
| 1054 | |||
| 1055 | # APs | ||
| 1056 | foreach my $idx ( keys %$ap_sw_ver ) { | ||
| 1057 | my $sw_ver = $ap_sw_ver->{$idx}; | ||
| 1058 | next unless defined $sw_ver; | ||
| 1059 | |||
| 1060 | $e_swver{$idx} = "$sw_ver"; | ||
| 1061 | } | ||
| 1062 | |||
| 1063 | return \%e_swver; | ||
| 1064 | } | ||
| 1065 | |||
| 1066 | sub e_vendor { | ||
| 1067 | my $aruba = shift; | ||
| 1068 | |||
| 1069 | my $e_idx = $aruba->e_index() || {}; | ||
| 1070 | |||
| 1071 | my %e_vendor; | ||
| 1072 | foreach my $iid ( keys %$e_idx ) { | ||
| 1073 | $e_vendor{$iid} = 'aruba'; | ||
| 1074 | } | ||
| 1075 | return \%e_vendor; | ||
| 1076 | } | ||
| 1077 | |||
| 1078 | sub e_serial { | ||
| 1079 | my $aruba = shift; | ||
| 1080 | |||
| 1081 | my $ap_serial = $aruba->aruba_ap_serial() || {}; | ||
| 1082 | my $card_serial = $aruba->aruba_card_serial() || {}; | ||
| 1083 | |||
| 1084 | my %e_serial; | ||
| 1085 | |||
| 1086 | # Chassis | ||
| 1087 | $e_serial{0} = $aruba->serial() || ''; | ||
| 1088 | |||
| 1089 | # Cards | ||
| 1090 | foreach my $iid ( keys %$card_serial ) { | ||
| 1091 | my $serial = $card_serial->{$iid}; | ||
| 1092 | next unless defined $serial; | ||
| 1093 | |||
| 1094 | $e_serial{$iid} = $serial; | ||
| 1095 | } | ||
| 1096 | |||
| 1097 | # APs | ||
| 1098 | foreach my $iid ( keys %$ap_serial ) { | ||
| 1099 | my $serial = $ap_serial->{$iid}; | ||
| 1100 | next unless defined $serial; | ||
| 1101 | |||
| 1102 | $e_serial{$iid} = $serial; | ||
| 1103 | } | ||
| 1104 | return \%e_serial; | ||
| 1105 | } | ||
| 1106 | |||
| 1107 | sub e_pos { | ||
| 1108 | my $aruba = shift; | ||
| 1109 | |||
| 1110 | my $e_idx = $aruba->e_index() || {}; | ||
| 1111 | |||
| 1112 | my %e_pos; | ||
| 1113 | |||
| 1114 | # $pos is for AP's, set it high enough that cards come first | ||
| 1115 | my $pos = 100; | ||
| 1116 | foreach my $iid ( sort keys %$e_idx ) { | ||
| 1117 | if ( $iid eq 0 ) { | ||
| 1118 | $e_pos{$iid} = -1; | ||
| 1119 | next; | ||
| 1120 | } | ||
| 1121 | elsif ( $iid =~ /^\d+$/ ) { | ||
| 1122 | $e_pos{$iid} = $iid; | ||
| 1123 | next; | ||
| 1124 | } | ||
| 1125 | else { | ||
| 1126 | $pos++; | ||
| 1127 | $e_pos{$iid} = $pos; | ||
| 1128 | } | ||
| 1129 | } | ||
| 1130 | return \%e_pos; | ||
| 1131 | } | ||
| 1132 | |||
| 1133 | sub e_parent { | ||
| 1134 | my $aruba = shift; | ||
| 1135 | |||
| 1136 | my $e_idx = $aruba->e_index() || {}; | ||
| 1137 | |||
| 1138 | my %e_parent; | ||
| 1139 | foreach my $iid ( sort keys %$e_idx ) { | ||
| 1140 | if ( $iid eq 0 ) { | ||
| 1141 | $e_parent{$iid} = 0; | ||
| 1142 | next; | ||
| 1143 | } | ||
| 1144 | else { | ||
| 1145 | $e_parent{$iid} = 1; | ||
| 1146 | } | ||
| 1147 | } | ||
| 1148 | return \%e_parent; | ||
| 1149 | } | ||
| 1150 | |||
| 1151 | # arpnip: | ||
| 1152 | # | ||
| 1153 | # This is the controller snooping on the MAC->IP mappings. | ||
| 1154 | # Pretending this is arpnip data allows us to get MAC->IP | ||
| 1155 | # mappings even for stations that only communicate locally. | ||
| 1156 | |||
| 1157 | # We also use the controller's knowledge of the APs' MAC and | ||
| 1158 | # IP addresses to augment the data. | ||
| 1159 | |||
| 1160 | sub at_paddr { | ||
| 1161 | my $aruba = shift; | ||
| 1162 | my $user_mac = $aruba->aruba_user_bssid(); | ||
| 1163 | |||
| 1164 | my $ap_ip = $aruba->aruba_ap_ip(); | ||
| 1165 | |||
| 1166 | my %at_paddr; | ||
| 1167 | foreach my $idx ( keys %$user_mac ) { | ||
| 1168 | $idx =~ s/(.\d+){4}$//; | ||
| 1169 | my $mac = join( ":", map { sprintf "%02x", $_ } split /\./, $idx ); | ||
| 1170 | next unless $mac; | ||
| 1171 | $at_paddr{$idx} = $mac; | ||
| 1172 | } | ||
| 1173 | |||
| 1174 | foreach my $idx ( keys %$ap_ip ) { | ||
| 1175 | next if ( $ap_ip->{$idx} eq '0.0.0.0' ); | ||
| 1176 | my $mac = join( ":", map { sprintf "%02x", $_ } split /\./, $idx ); | ||
| 1177 | $at_paddr{$idx} = $mac; | ||
| 1178 | } | ||
| 1179 | return \%at_paddr; | ||
| 1180 | } | ||
| 1181 | |||
| 1182 | sub at_netaddr { | ||
| 1183 | my $aruba = shift; | ||
| 1184 | my $user_mac = $aruba->aruba_user_bssid(); | ||
| 1185 | |||
| 1186 | my $ap_ip = $aruba->aruba_ap_ip(); | ||
| 1187 | |||
| 1188 | my %at_netaddr; | ||
| 1189 | |||
| 1190 | foreach my $idx ( keys %$ap_ip ) { | ||
| 1191 | next if ( $ap_ip->{$idx} eq '0.0.0.0' ); | ||
| 1192 | $at_netaddr{$idx} = $ap_ip->{$idx}; | ||
| 1193 | } | ||
| 1194 | foreach my $idx ( keys %$user_mac ) { | ||
| 1195 | my @parts = split( /\./, $idx ); | ||
| 1196 | my $iid = join( ".", splice( @parts, 0, 6 ) ); | ||
| 1197 | my $ip = join( ".", @parts ); | ||
| 1198 | next unless ( $ip =~ /^(\d+\.){3}(\d+)$/ ); | ||
| 1199 | next if ( $idx eq '0.0.0.0' ); | ||
| 1200 | $at_netaddr{$iid} = $ip; | ||
| 1201 | } | ||
| 1202 | return \%at_netaddr; | ||
| 1203 | } | ||
| 1204 | |||
| 1205 | sub munge_aruba_fqln { | ||
| 1206 | my $loc = shift; | ||
| 1207 | $loc =~ s/\\\.0//g; | ||
| 1208 | return $loc; | ||
| 1209 | } | ||
| 1210 | |||
| 1211 | # The index of wlsxPsePortTable is wlsxPsePortIndex which equals | ||
| 1212 | # ifIndex; however, to emulate POWER-ETHERNET-MIB we need a "module.port" | ||
| 1213 | # index. If ifDescr has the format x/x/x use it to determine the module | ||
| 1214 | # otherwise default to 1. Unfortunately, this means we can't map any | ||
| 1215 | # wlsxPsePortTable leafs directly and partials will not be supported. | ||
| 1216 | sub peth_port_ifindex { | ||
| 1217 | my $aruba = shift; | ||
| 1218 | |||
| 1219 | my $indexes = $aruba->wlsxPsePortAdminStatus(); | ||
| 1220 | my $descrs = $aruba->i_description(); | ||
| 1221 | |||
| 1222 | my $peth_port_ifindex = {}; | ||
| 1223 | foreach my $i ( keys %$indexes ) { | ||
| 1224 | my $descr = $descrs->{$i}; | ||
| 1225 | next unless $descr; | ||
| 1226 | |||
| 1227 | my $new_idx = "1.$i"; | ||
| 1228 | |||
| 1229 | if ( $descr =~ /(\d+)\/\d+\/\d+/ ) { | ||
| 1230 | $new_idx = "$1.$i"; | ||
| 1231 | } | ||
| 1232 | $peth_port_ifindex->{$new_idx} = $i; | ||
| 1233 | } | ||
| 1234 | return $peth_port_ifindex; | ||
| 1235 | } | ||
| 1236 | |||
| 1237 | sub peth_port_admin { | ||
| 1238 | my $aruba = shift; | ||
| 1239 | |||
| 1240 | my $p_index = $aruba->peth_port_ifindex() || {}; | ||
| 1241 | my $admin_states = $aruba->wlsxPsePortAdminStatus() || {}; | ||
| 1242 | |||
| 1243 | my $peth_port_admin = {}; | ||
| 1244 | foreach my $i ( keys %$p_index ) { | ||
| 1245 | my ( $module, $port ) = split( /\./, $i ); | ||
| 1246 | my $state = $admin_states->{$port}; | ||
| 1247 | |||
| 1248 | if ( $state =~ /enable/ ) { | ||
| 1249 | $peth_port_admin->{$i} = 'true'; | ||
| 1250 | } | ||
| 1251 | else { | ||
| 1252 | $peth_port_admin->{$i} = 'false'; | ||
| 1253 | } | ||
| 1254 | } | ||
| 1255 | return $peth_port_admin; | ||
| 1256 | } | ||
| 1257 | |||
| 1258 | sub peth_port_neg_power { | ||
| 1259 | my $aruba = shift; | ||
| 1260 | |||
| 1261 | my $p_index = $aruba->peth_port_ifindex() || {}; | ||
| 1262 | my $port_alloc = $aruba->wlsxPsePortPowerAllocated() || {}; | ||
| 1263 | |||
| 1264 | my $peth_port_neg_power = {}; | ||
| 1265 | foreach my $i ( keys %$p_index ) { | ||
| 1266 | my ( $module, $port ) = split( /\./, $i ); | ||
| 1267 | my $power = $port_alloc->{$port}; | ||
| 1268 | next unless $power; | ||
| 1269 | |||
| 1270 | $peth_port_neg_power->{$i} = $power; | ||
| 1271 | } | ||
| 1272 | return $peth_port_neg_power; | ||
| 1273 | } | ||
| 1274 | |||
| 1275 | sub peth_port_power { | ||
| 1276 | my $aruba = shift; | ||
| 1277 | |||
| 1278 | my $p_index = $aruba->peth_port_ifindex() || {}; | ||
| 1279 | my $port_consumed = $aruba->wlsxPsePortPowerConsumed() || {}; | ||
| 1280 | |||
| 1281 | my $peth_port_power = {}; | ||
| 1282 | foreach my $i ( keys %$p_index ) { | ||
| 1283 | my ( $module, $port ) = split( /\./, $i ); | ||
| 1284 | my $power = $port_consumed->{$port}; | ||
| 1285 | next unless $power; | ||
| 1286 | |||
| 1287 | $peth_port_power->{$i} = $power; | ||
| 1288 | } | ||
| 1289 | return $peth_port_power; | ||
| 1290 | } | ||
| 1291 | |||
| 1292 | sub peth_port_class { | ||
| 1293 | my $aruba = shift; | ||
| 1294 | |||
| 1295 | my $p_index = $aruba->peth_port_ifindex() || {}; | ||
| 1296 | my $port_class = $aruba->wlsxPsePortPdClass() || {}; | ||
| 1297 | |||
| 1298 | my $peth_port_class = {}; | ||
| 1299 | foreach my $i ( keys %$p_index ) { | ||
| 1300 | my ( $module, $port ) = split( /\./, $i ); | ||
| 1301 | my $power = $port_class->{$port}; | ||
| 1302 | next unless $power; | ||
| 1303 | |||
| 1304 | $peth_port_class->{$i} = $power; | ||
| 1305 | } | ||
| 1306 | return $peth_port_class; | ||
| 1307 | } | ||
| 1308 | |||
| 1309 | sub peth_port_status { | ||
| 1310 | my $aruba = shift; | ||
| 1311 | |||
| 1312 | my $p_index = $aruba->peth_port_ifindex() || {}; | ||
| 1313 | my $admin_states = $aruba->wlsxPsePortState() || {}; | ||
| 1314 | |||
| 1315 | my $peth_port_status = {}; | ||
| 1316 | foreach my $i ( keys %$p_index ) { | ||
| 1317 | my ( $module, $port ) = split( /\./, $i ); | ||
| 1318 | my $state = $admin_states->{$port}; | ||
| 1319 | |||
| 1320 | if ( $state eq 'on' ) { | ||
| 1321 | $peth_port_status->{$i} = 'deliveringPower'; | ||
| 1322 | } | ||
| 1323 | else { | ||
| 1324 | $peth_port_status->{$i} = 'disabled'; | ||
| 1325 | } | ||
| 1326 | } | ||
| 1327 | return $peth_port_status; | ||
| 1328 | } | ||
| 1329 | |||
| 1330 | sub peth_power_status { | ||
| 1331 | my $aruba = shift; | ||
| 1332 | my $partial = shift; | ||
| 1333 | |||
| 1334 | my $watts = $aruba->wlsxPseSlotPowerAvailable($partial) || {}; | ||
| 1335 | |||
| 1336 | my $offset = (exists $watts->{0}) ? 1 : 0; | ||
| 1337 | |||
| 1338 | my $peth_power_status = {}; | ||
| 1339 | foreach my $i ( keys %$watts ) { | ||
| 1340 | $peth_power_status->{$i + $offset} = 'on'; | ||
| 1341 | } | ||
| 1342 | return $peth_power_status; | ||
| 1343 | } | ||
| 1344 | |||
| 1345 | sub peth_power_watts { | ||
| 1346 | my $aruba = shift; | ||
| 1347 | my $partial = shift; | ||
| 1348 | |||
| 1349 | my $watts_total = $aruba->wlsxPseSlotPowerAvailable($partial) || {}; | ||
| 1350 | |||
| 1351 | my $offset = (exists $watts_total->{0}) ? 1 : 0; | ||
| 1352 | |||
| 1353 | my $peth_power_watts = {}; | ||
| 1354 | foreach my $i ( keys %$watts_total ) { | ||
| 1355 | my $total = $watts_total->{$i}; | ||
| 1356 | next unless $total; | ||
| 1357 | |||
| 1358 | $peth_power_watts->{$i + $offset} = $total; | ||
| 1359 | } | ||
| 1360 | return $peth_power_watts; | ||
| 1361 | } | ||
| 1362 | |||
| 1363 | sub peth_power_consumption { | ||
| 1364 | my $aruba = shift; | ||
| 1365 | |||
| 1366 | my $watts = $aruba->wlsxPseSlotPowerConsumption() || {}; | ||
| 1367 | |||
| 1368 | my $offset = (exists $watts->{0}) ? 1 : 0; | ||
| 1369 | |||
| 1370 | my $peth_power_consumed = {}; | ||
| 1371 | foreach my $i ( keys %$watts ) { | ||
| 1372 | my $total = $watts->{$i}; | ||
| 1373 | next unless $total; | ||
| 1374 | |||
| 1375 | $peth_power_consumed->{$i + $offset} = $total; | ||
| 1376 | } | ||
| 1377 | return $peth_power_consumed; | ||
| 1378 | } | ||
| 1379 | |||
| 1380 | 1; | ||
| 1381 | |||
| 1382 | __END__ |