| 1 | package Cisco::SNMP::Image; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | ################################################## | ||||||||||||||||||||
| 4 | # AUTHOR = Michael Vincent | ||||||||||||||||||||
| 5 | # www.VinsWorld.com | ||||||||||||||||||||
| 6 | ################################################## | ||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 3 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 3 | ▶ | use Net::SNMP qw(:asn1); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | 3 | ▶ | use Cisco::SNMP; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 3 | our $VERSION = $Cisco::SNMP::VERSION; | |||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 3 | our @ISA = qw(Cisco::SNMP); | |||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | ################################################## | ||||||||||||||||||||
| 19 | # Start Public Module | ||||||||||||||||||||
| 20 | ################################################## | ||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 0 | ▶ | sub _imageOID { | ||||||||||||||||||
|
Subroutine
_imageOID: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 23 | 0 | return '.1.3.6.1.4.1.9.9.25.1.1.1.2'; | |||||||||||||||||||
| 24 | } | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 0 | ▶ | sub image_info { | ||||||||||||||||||
|
Subroutine
image_info: not called CC=5 SCAR=29.0
Pod
documented
| |||||||||||||||||||||
| 27 | 0 | my $self = shift; | |||||||||||||||||||
| 28 | 0 | ▶ | my $class = ref($self) || $self; | ||||||||||||||||||
|
Condition0%0/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table0%0/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 0 | my $session = $self->{_SESSION_}; | |||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 0 | my $response = Cisco::SNMP::_snmpwalk( $session, _imageOID() ); | |||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 0 | my %ImageHash; | |||||||||||||||||||
| 35 | 0 | for ( @{$response} ) { | |||||||||||||||||||
| 36 | 0 | my ( $key, $value ) = split /\$/, $_, 2; | |||||||||||||||||||
| 37 | 0 | $key =~ s/^CW_//; | |||||||||||||||||||
| 38 | 0 | $key = ucfirst( lc($key) ); | |||||||||||||||||||
| 39 | 0 | $value =~ s/\$$//; | |||||||||||||||||||
| 40 | 0 | $ImageHash{$key} = $value; | |||||||||||||||||||
| 41 | } | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 3 | ▶ | no strict 'refs'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 44 | 0 | for my $key ( keys(%ImageHash) ) { | |||||||||||||||||||
| 45 | 0 | ▶ | *{"image" . $key} = sub { | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 46 | 0 | return $ImageHash{$key}; | |||||||||||||||||||
| 47 | } | ||||||||||||||||||||
| 48 | 0 | } | |||||||||||||||||||
| 49 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 0 | ▶ | if ( defined $response ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 52 | 0 | return bless $response, $class; | |||||||||||||||||||
| 53 | } else { | ||||||||||||||||||||
| 54 | 0 | $Cisco::SNMP::LASTERROR = "Cannot read image MIB"; | |||||||||||||||||||
| 55 | 0 | return undef; | |||||||||||||||||||
| 56 | } | ||||||||||||||||||||
| 57 | } | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 0 | ▶ | sub imageString { | ||||||||||||||||||
|
Subroutine
imageString: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 60 | 0 | my $self = shift; | |||||||||||||||||||
| 61 | 0 | my ($idx) = @_; | |||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | 0 | ▶ | if ( not defined $idx ) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 64 | 0 | $idx = 0; | |||||||||||||||||||
| 65 | } elsif ( $idx !~ /^\d+$/ ) { | ||||||||||||||||||||
| 66 | 0 | $Cisco::SNMP::LASTERROR = "Invalid image index `$idx'"; | |||||||||||||||||||
| 67 | 0 | return undef; | |||||||||||||||||||
| 68 | } | ||||||||||||||||||||
| 69 | 0 | return $self->[$idx]; | |||||||||||||||||||
| 70 | } | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | 0 | ▶ | sub get_imageString { | ||||||||||||||||||
|
Subroutine
get_imageString: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 73 | 0 | my $self = shift; | |||||||||||||||||||
| 74 | 0 | my ($idx) = @_; | |||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | 0 | my $s = $self->session; | |||||||||||||||||||
| 77 | 0 | my $r = $s->get_request( varbindlist => [_imageOID() . '.' . ($idx)] ); | |||||||||||||||||||
| 78 | 0 | return $r->{_imageOID() . '.' . ($idx)}; | |||||||||||||||||||
| 79 | } | ||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | ################################################## | ||||||||||||||||||||
| 82 | # End Public Module | ||||||||||||||||||||
| 83 | ################################################## | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | 3 | 1; | |||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | __END__ | ||||||||||||||||||||