| 1 | package SNMP::Insight::Device::Cisco::Catalyst; | ||
| 2 | |||
| 3 | # ABSTRACT: Support for Cisco Catalyst devices | ||
| 4 | |||
| 5 | use Moose::Role; | ||
| 6 | use namespace::autoclean; | ||
| 7 | |||
| 8 | our $VERSION = '0.002'; #TRIAL VERSION: | ||
| 9 | |||
| 10 | with | ||
| 11 | 'SNMP::Insight::Device::Cisco::L2Device', | ||
| 12 | |||
| 13 | # 'SNMP::Insight::MIB::Cisco::Stack', | ||
| 14 | ; | ||
| 15 | |||
| 16 | sub os { | ||
| 17 | my $self = shift; | ||
| 18 | my $descr = $self->sysDescr || ''; | ||
| 19 | |||
| 20 | # order here matters - there are Catalysts that run IOS and have catalyst | ||
| 21 | # in their description field. | ||
| 22 | return 'ios' if ( $descr =~ /IOS/ ); | ||
| 23 | return 'catalyst' if ( $descr =~ /catalyst/i ); | ||
| 24 | return; | ||
| 25 | } | ||
| 26 | |||
| 27 | sub model { | ||
| 28 | my $self = shift; | ||
| 29 | my $id = $self->sysObjectID; | ||
| 30 | |||
| 31 | unless ( defined $id ) { | ||
| 32 | return; | ||
| 33 | } | ||
| 34 | |||
| 35 | my $model = $self->translate($id); | ||
| 36 | |||
| 37 | return $id unless defined $model; | ||
| 38 | |||
| 39 | $model =~ s/^cisco//i; | ||
| 40 | $model =~ s/^catalyst//; | ||
| 41 | $model =~ s/^cat//; | ||
| 42 | return $model; | ||
| 43 | } | ||
| 44 | |||
| 45 | sub os_ver { | ||
| 46 | my $self = shift; | ||
| 47 | my $os = $self->os(); | ||
| 48 | my $descr = $self->sysDescr(); | ||
| 49 | |||
| 50 | # Older Catalysts | ||
| 51 | if ( defined $os | ||
| 52 | and $os eq 'catalyst' | ||
| 53 | and defined $descr | ||
| 54 | and $descr =~ m/V(\d{1}\.\d{2}\.\d{2})/ ) | ||
| 55 | { | ||
| 56 | return $1; | ||
| 57 | } | ||
| 58 | |||
| 59 | # Newer Catalysts and IOS devices | ||
| 60 | if ( defined $descr | ||
| 61 | and $descr =~ m/Version (\d+\.\d+\([^)]+\)[^,\s]*)(,|\s)+/ ) | ||
| 62 | { | ||
| 63 | return $1; | ||
| 64 | } | ||
| 65 | return; | ||
| 66 | } | ||
| 67 | |||
| 68 | 1; | ||
| 69 | |||
| 70 | # Local Variables: | ||
| 71 | # mode: cperl | ||
| 72 | # indent-tabs-mode: nil | ||
| 73 | # cperl-indent-level: 4 | ||
| 74 | # cperl-indent-parens-as-block: t | ||
| 75 | # End: | ||
| 76 | |||
| 77 | __END__ |