Support offline update of oui.txt and MIBs bundle

This commit is contained in:
Oliver Gorwits
2014-05-21 19:40:31 +01:00
parent 62581f99e4
commit ef4a94ae79
5 changed files with 54 additions and 8 deletions

View File

@@ -1,5 +1,9 @@
2.027005 - 2014-05-15 2.027005 - 2014-05-15
[ENHANCEMENTS]
* Support offline update of oui.txt and MIBs bundle
[BUG FIXES] [BUG FIXES]
* Improve VLAN Inventory performance and show all VLANs (C. Stromsoe) * Improve VLAN Inventory performance and show all VLANs (C. Stromsoe)

View File

@@ -20,6 +20,7 @@ requires 'Dancer::Plugin::DBIC' => 0.2001;
requires 'Dancer::Plugin::Auth::Extensible' => 0.30; requires 'Dancer::Plugin::Auth::Extensible' => 0.30;
requires 'Dancer::Plugin::Passphrase' => '2.0.1'; requires 'Dancer::Plugin::Passphrase' => '2.0.1';
requires 'File::ShareDir' => 1.03; requires 'File::ShareDir' => 1.03;
requires 'File::Slurp' => 9999.19;
requires 'Guard' => 1.022; requires 'Guard' => 1.022;
requires 'HTML::Parser' => 3.70; requires 'HTML::Parser' => 3.70;
requires 'HTTP::Tiny' => 0.029; requires 'HTTP::Tiny' => 0.029;

View File

@@ -50,6 +50,7 @@ use Term::ANSIColor;
use Archive::Extract; use Archive::Extract;
$Archive::Extract::PREFER_BIN = 1; $Archive::Extract::PREFER_BIN = 1;
use File::Slurp ();
use HTTP::Tiny; use HTTP::Tiny;
use Digest::MD5; use Digest::MD5;
use Try::Tiny; use Try::Tiny;
@@ -182,13 +183,20 @@ sub deploy_db {
sub deploy_oui { sub deploy_oui {
my $schema = schema('netdisco'); my $schema = schema('netdisco');
$schema->storage->disconnect; $schema->storage->disconnect;
my @lines = ();
my $url = 'http://standards.ieee.org/develop/regauth/oui/oui.txt';
my $resp = HTTP::Tiny->new->get($url);
my %data = (); my %data = ();
if ($resp->{success}) { if (@ARGV) {
foreach my $line (split /\n/, $resp->{content}) { @lines = File::Slurp::read_file($ARGV[0], err_mode => 'quiet');
}
else {
my $url = 'http://standards.ieee.org/develop/regauth/oui/oui.txt';
my $resp = HTTP::Tiny->new->get($url);
@lines = split /\n/, $resp->{content};
}
if (scalar @lines) {
foreach my $line (@lines) {
if ($line =~ m/^\s*(.{2}-.{2}-.{2})\s+\(hex\)\s+(.*)\s*$/i) { if ($line =~ m/^\s*(.{2}-.{2}-.{2})\s+\(hex\)\s+(.*)\s*$/i) {
my ($oui, $company) = ($1, $2); my ($oui, $company) = ($1, $2);
$oui =~ s/-/:/g; $oui =~ s/-/:/g;
@@ -211,10 +219,15 @@ sub deploy_oui {
]); ]);
}); });
} }
print color 'bold blue';
say 'OUI update complete.';
}
else {
print color 'bold red';
say 'OUI update failed.';
} }
print color 'bold blue';
say 'OUI update complete.';
print color 'reset'; print color 'reset';
} }

View File

@@ -212,7 +212,9 @@ take care of all this for you:
~/bin/netdisco-deploy ~/bin/netdisco-deploy
If this is a new installation of Netdisco 2, answer yes to all questions. If this is a new installation of Netdisco 2, answer yes to all questions. If
you wish to deploy without Internet access, see the
L<Deployment|App::Netdisco::Manual::Deployment> documentation.
=head1 Startup =head1 Startup

View File

@@ -28,6 +28,32 @@ the database service):
# TYPE DATABASE USER ADDRESS METHOD # TYPE DATABASE USER ADDRESS METHOD
host all all 127.0.0.1/32 md5 host all all 127.0.0.1/32 md5
=head1 Deploy without Internet access
The C<netdisco-deploy> script asks for Internet access but it is possible to
install off-line. You should download the following two files:
=over 4
=item *
http://standards.ieee.org/develop/regauth/oui/oui.txt
=item *
http://downloads.sourceforge.net/project/netdisco/netdisco-mibs/latest-snapshot/netdisco-mibs-snapshot.tar.gz
=back
Run the C<netdisco-deploy> script but pass the OUI file name as a parameter on
the command line:
~/bin/netdisco-deploy ./oui.txt
Then answer yes to questions, even though you're not connected to the
Internet. For the MIBs you can simply extract the downloaded archive to the
home directory of Netdisco.
=head1 Relocating the Installation =head1 Relocating the Installation
The installation process installs Netdisco self-contained to your home The installation process installs Netdisco self-contained to your home