WIP. Raisecom crap splitting

This commit is contained in:
Andrey Pazychev
2020-05-20 21:08:14 +03:00
parent 4cb3083993
commit b019f3fa06
2 changed files with 40 additions and 37 deletions

View File

@@ -16,15 +16,10 @@ our ($VERSION, %GLOBALS, %MIBS, %FUNCS, %MUNGE);
$VERSION = '3.70-135'; $VERSION = '3.70-135';
# This will be filled in with the device's index into the EntPhysicalEntry
# table by the serial() function.
# our $index = undef;
%MIBS = ( %SNMP::Info::Layer2::MIBS, ); %MIBS = ( %SNMP::Info::Layer2::MIBS, );
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::Layer2::GLOBALS, %SNMP::Info::Layer2::GLOBALS,
'serial_oid' => 'transmission.94.1.1.2.1.1.1',
); );
%FUNCS = ( %SNMP::Info::Layer2::FUNCS, ); %FUNCS = ( %SNMP::Info::Layer2::FUNCS, );
@@ -40,7 +35,6 @@ sub os {
} }
sub os_ver { sub os_ver {
my $obj = shift;
return 'unknown'; return 'unknown';
} }

View File

@@ -9,6 +9,7 @@ use warnings;
use Exporter; use Exporter;
use SNMP::Info::Layer3; use SNMP::Info::Layer3;
use SNMP::Info::Layer3::Rotek; use SNMP::Info::Layer3::Rotek;
use Data::Dumper;
@SNMP::Info::Layer3::Raisecom::ISA = qw/SNMP::Info::Layer3 Exporter/; @SNMP::Info::Layer3::Raisecom::ISA = qw/SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::Raisecom::EXPORT_OK = qw//; @SNMP::Info::Layer3::Raisecom::EXPORT_OK = qw//;
@@ -21,7 +22,7 @@ $VERSION = '3.70-135';
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::Layer3::GLOBALS, %SNMP::Info::Layer3::GLOBALS,
'model_oid' => 'mib-2.47.1.1.1.1.13.1', 'model_oid' => 'mib-2.47.1.1.1.1.13.1', #enterprises.8886.1.1.4.1.0
'model_oid_41752' => 'enterprises.41752.6.1.1.1.19.0', 'model_oid_41752' => 'enterprises.41752.6.1.1.1.19.0',
'model_oid_8886_6_140' => 'enterprises.8886.6.1.1.1.19.0', 'model_oid_8886_6_140' => 'enterprises.8886.6.1.1.1.19.0',
'serial_oid' => 'mib-2.47.1.1.1.1.11.1', 'serial_oid' => 'mib-2.47.1.1.1.1.11.1',
@@ -46,23 +47,49 @@ $VERSION = '3.70-135';
sub vendor { sub vendor {
my $obj = shift; my $obj = shift;
my $id = $obj->id(); return $obj->main($obj)->{vendor};
if ($id =~ /41752$/) {
return SNMP::Info::Layer3::Rotek::vendor($obj);
}
return 'raisecom';
} }
sub os { sub os {
my $obj = shift; my $obj = shift;
my $id = $obj->id(); return $obj->main($obj)->{os};
if ($id =~ /41752\.26\.502/ or $id =~ /8886\.6/) { }
return 'ros';
sub main {
my $obj = shift;
my $response = undef; my $serial = undef; my $model = undef; my $hw = undef; my $os_ver = undef; my $brom = undef;
my $vendor = 'raisecom'; my $os = 'rcios';
my $id = $obj->id;
#Rotek kostilyng
if ($id =~ /41752$/) {
my %rotek = ();#undef;#('vendor', 'os', 'model', 'os_ver', 'serial');
for my $key ('vendor', 'os', 'model', 'os_ver', 'serial') {
no strict 'refs';
my $sub = *{'SNMP::Info::Layer3::Rotek::'.$key};
$rotek{$key} = &$sub($obj);
}
return %rotek;
} }
elsif ($id =~ /41752$/) {
return SNMP::Info::Layer3::Rotek::os($obj); if ( $id =~ /41752\.26\.502/ ) {
$model = $obj->model_oid_41752 || undef;
$hw = ($obj->hw_oid_41752 =~ /.*\sversion\s(.*)/)[0];
} }
return 'rcios'; elsif ($id =~ /8886\.6\.(140|191|150|21[3,4])$/) {
$model = $obj->model_oid_8886_6_140 || undef;
$model = $obj->session()->get('enterprises.8886.1.1.4.1.0')
if not defined($model);
$hw = $obj->hw_oid_8886_6_140;
$hw =~ s/.*\s[v,V]ersion\s(.*)/$1/
if defined $1;
}
$model .= ' HW:' . $hw
if (defined($model) and defined($hw));
return { 'vendor' => $vendor, 'os' => $os, 'model' => $model, 'os_ver' => $os_ver, 'serial' => $serial };
} }
sub os_ver { sub os_ver {
@@ -111,25 +138,7 @@ sub os_ver {
} }
sub model { sub model {
my $obj = shift; my $obj = shift;
my $id = $obj->id(); return $obj->main($obj)->{model};
my $model = $obj->model_oid || undef;
my $hw = $obj->hw_oid || undef;
if (defined $model and defined $hw) {
return $model . ' HW:' . $hw;
}
elsif (defined $model) {
return $model;
}
elsif ($id =~ /41752\.26\.502/) {
return $obj->model_oid_41752 . ' HW:' . $obj->hvver;
}
elsif ($id =~ /8886\.6\.(140|191|150|21[3,4])$/) {
return $obj->model_oid_8886_6_140 . ' HW:' . $obj->hvver;
}
elsif ($id =~ /41752$/) {
return SNMP::Info::Layer3::Rotek::model($obj);
}
return $obj->SUPER::model();
} }
sub serial { sub serial {