UBNT EdgeMax version reporting (#350)
* Clean up EdgeOS and EdgeSwitch verion reporting * Fixes EdgeOS hotfix versioning * Also clean up AirOS firmware
This commit is contained in:
@@ -70,14 +70,14 @@ sub os {
|
|||||||
my $prod = $names->{$iid};
|
my $prod = $names->{$iid};
|
||||||
next unless defined $prod;
|
next unless defined $prod;
|
||||||
# Product names that match AirOS products
|
# Product names that match AirOS products
|
||||||
if((lc $prod) =~ /station/ or (lc $prod) =~ /beam/ or (lc $prod) =~ /grid/){
|
if((lc $prod) =~ /station/ or (lc $prod) =~ /beam/ or (lc $prod) =~ /grid/){
|
||||||
return 'AirOS';
|
return 'AirOS';
|
||||||
# Product names that match UAP
|
# Product names that match UAP
|
||||||
}elsif((lc $prod) =~ /uap/){
|
}elsif((lc $prod) =~ /uap/){
|
||||||
return 'UniFi';
|
return 'UniFi';
|
||||||
}else{
|
}else{
|
||||||
# Continue below to find OS name
|
# Continue below to find OS name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
## EdgeMAX OS (EdgeSwitch and EdgeRouter) name is first field split by space
|
## EdgeMAX OS (EdgeSwitch and EdgeRouter) name is first field split by space
|
||||||
@@ -89,31 +89,50 @@ sub os {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub os_ver {
|
sub os_ver {
|
||||||
my $dot11 = shift;
|
my $ubnt = shift;
|
||||||
|
|
||||||
my $versions = $dot11->dot11_prod_ver();
|
my $versions = $ubnt->dot11_prod_ver();
|
||||||
|
|
||||||
foreach my $iid ( keys %$versions ) {
|
foreach my $iid ( keys %$versions ) {
|
||||||
my $ver = $versions->{$iid};
|
my $ver = $versions->{$iid};
|
||||||
next unless defined $ver;
|
next unless defined $ver;
|
||||||
|
my $os = $ubnt->os;
|
||||||
|
if($os == 'AirOS'){
|
||||||
|
## pretty up the version reporting for AirOS to include hardware (XW, XM, etc) and three major groups of firmware
|
||||||
|
my @firmware = split(/v/, $ver);
|
||||||
|
my @firmwareSplit = split(/\./, $firmware[1]);
|
||||||
|
my @prefix = split(/\./, $ver);
|
||||||
|
$ver = $prefix[0] . '-v' . join('.', @firmwareSplit[0,1,2]);
|
||||||
|
}
|
||||||
return $ver;
|
return $ver;
|
||||||
## Not sure what this function does, it seems to be extraneous being in the same code block after a return statement?
|
## Not sure what this function does, it seems to be extraneous being in the same code block after a return statement?
|
||||||
if ( $ver =~ /([\d\.]+)/ ) {
|
#if ( $ver =~ /([\d\.]+)/ ) {
|
||||||
return $1;
|
# return $1;
|
||||||
}
|
#}
|
||||||
}
|
}
|
||||||
my $ver = $dot11->description() || '';
|
|
||||||
if($ver =~ /^edgeswitch/){
|
|
||||||
## EdgeSwitch OS version is second field split by comma
|
|
||||||
my @myver = split(/, /, $ver);
|
|
||||||
|
|
||||||
return $myver[1];
|
my $ver = $ubnt->description() || '';
|
||||||
|
if((lc $ver) =~ /^edgeswitch/){
|
||||||
|
## EdgeSwitch OS version is second field split by comma and bootcode version is last
|
||||||
|
my @myver = split(/, /, $ver);
|
||||||
|
my @firmware = split(/\./, $myver[1]);
|
||||||
|
my @bootcode = split(/\./, $myver[-1]);
|
||||||
|
|
||||||
|
## Return only three major version groupings and include bootcode version
|
||||||
|
return join('.', @firmware[0,1,2]) . '.-b' . join('.', @bootcode[0,1,2]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
## EdgeRouter OS version is second field split by space
|
## EdgeRouter OS version is second field split by space
|
||||||
my @myver = split(/ /, $ver);
|
my @myver = split(/ /, $ver);
|
||||||
|
my @firmware = split(/\./, $myver[1]);
|
||||||
|
|
||||||
return $myver[1];
|
if($firmware[2] =~ /hotfix$/){
|
||||||
|
# edge case where EdgeOS has hotfix versions in format "EdgeOS v1.9.7+hotfix.4.5024004.171005.0403"
|
||||||
|
$firmware[2] = $firmware[2] . '.' . $firmware[3]
|
||||||
|
}
|
||||||
|
## Return only three major version groupings
|
||||||
|
return join('.', @firmware[0,1,2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub vendor {
|
sub vendor {
|
||||||
@@ -142,7 +161,7 @@ sub model {
|
|||||||
if(!((lc $desc) =~ /edgeos/)){
|
if(!((lc $desc) =~ /edgeos/)){
|
||||||
# Not sure what type of device this is to get Model
|
# Not sure what type of device this is to get Model
|
||||||
# Wireless devices report dot11_prod_name
|
# Wireless devices report dot11_prod_name
|
||||||
# EdgeSwitch includes mode directly and edgeos logic is in else statement
|
# EdgeSwitch includes model directly and edgeos logic is in else statement
|
||||||
return ;
|
return ;
|
||||||
}else{
|
}else{
|
||||||
## do some logic to determine ER model based on tech specs from ubnt:
|
## do some logic to determine ER model based on tech specs from ubnt:
|
||||||
|
|||||||
Reference in New Issue
Block a user