much better handling of mibhome

This commit is contained in:
Oliver Gorwits
2013-04-19 23:36:06 +01:00
parent d735cc657d
commit 9875c70f41
5 changed files with 30 additions and 12 deletions

View File

@@ -96,15 +96,27 @@ deploy_db() if $bool;
say ''; say '';
$bool = $term->ask_yn( $bool = $term->ask_yn(
prompt => 'Would you like to download and update vendor MAC prefixes (OUI data)?', default => 'n', prompt => 'Download and update vendor MAC prefixes (OUI data)?', default => 'n',
); );
deploy_oui() if $bool; deploy_oui() if $bool;
say ''; say '';
$bool = $term->ask_yn( my $default_mibhome = dir($home, 'netdisco-mibs');
prompt => 'Would you like to download and update MIB files?', default => 'n', if (setting('mibhome') and setting('mibhome') ne $default_mibhome) {
); my $mibhome = $term->get_reply(
deploy_mibs() if $bool; print_me => "MIB home options:",
prompt => "Download and update MIB files to...?",
choices => [setting('mibhome'), $default_mibhome, 'Skip this.'],
default => 'Skip this.',
);
deploy_mibs($mibhome) if $mibhome and $mibhome ne 'Skip this.';
}
else {
$bool = $term->ask_yn(
prompt => "Download and update MIB files to $default_mibhome ?", default => 'n',
);
deploy_mibs($default_mibhome) if $bool;
}
sub deploy_db { sub deploy_db {
system 'netdisco-db-deploy'; system 'netdisco-db-deploy';
@@ -142,13 +154,15 @@ sub deploy_oui {
} }
sub deploy_mibs { sub deploy_mibs {
my $mibhome = shift;
my $url = 'http://downloads.sourceforge.net/project/netdisco/netdisco-mibs/latest-snapshot/netdisco-mibs-snapshot.tar.gz'; my $url = 'http://downloads.sourceforge.net/project/netdisco/netdisco-mibs/latest-snapshot/netdisco-mibs-snapshot.tar.gz';
my $file = file($home, 'netdisco-mibs-snapshot.tar.gz'); my $file = file($home, 'netdisco-mibs-snapshot.tar.gz');
my $resp = HTTP::Tiny->new->mirror($url, $file); my $resp = HTTP::Tiny->new->mirror($url, $file);
if ($resp->{success}) { if ($resp->{success}) {
my $ae = Archive::Extract->new(archive => $file, type => 'tgz'); my $ae = Archive::Extract->new(archive => $file, type => 'tgz');
$ae->extract(to => $home); $ae->extract(to => $mibhome);
unlink $file; unlink $file;
} }

View File

@@ -147,7 +147,8 @@ sub _try_connect {
} }
sub _build_mibdirs { sub _build_mibdirs {
return map { dir(setting('mibhome'), $_) } my $home = (setting('mibhome') || $ENV{NETDISCO_HOME} || $ENV{HOME});
return map { dir($home, $_) }
@{ setting('mibdirs') || [] }; @{ setting('mibdirs') || [] };
} }

View File

@@ -3,7 +3,7 @@
# Web app env-related settings should go to environments/$env.yml # Web app env-related settings should go to environments/$env.yml
# Your application's name # application's name
appname: "Netdisco" appname: "Netdisco"
# The default web layout to use for your application (located in # The default web layout to use for your application (located in
@@ -33,7 +33,7 @@ engines:
end_tag: '%]' end_tag: '%]'
PRE_CHOMP: 1 PRE_CHOMP: 1
# netdisco stuff (can be overidden in the environment .yml) # Netdisco stuff (can be overidden in the environment .yml)
web_plugins: web_plugins:
- Inventory - Inventory
@@ -55,7 +55,12 @@ snmpver: 2
snmpretries: 2 snmpretries: 2
snmptimeout: 1000000 snmptimeout: 1000000
mibhome: /usr/share/netdisco/mibs # If unset, Netdisco uses "NETDISCO_HOME/netdisco-mibs", assuming you're
# using the netdisco-deploy script to download MIBs there. Otherwise, set
# this, for example:
#
# mibhome: /usr/share/netdisco/mibs
mibdirs: mibdirs:
- cisco - cisco
- rfc - rfc

View File

@@ -37,7 +37,6 @@ plugins:
# local settings for Netdisco poller and port changes # local settings for Netdisco poller and port changes
mibhome: '/home/netdisco/netdisco-mibs'
mibdirs: mibdirs:
- cisco - cisco
- rfc - rfc

View File

@@ -39,7 +39,6 @@ no_auth: 1
# local settings for Netdisco poller and port changes # local settings for Netdisco poller and port changes
mibhome: '/home/netdisco/netdisco-mibs'
mibdirs: mibdirs:
- cisco - cisco
- rfc - rfc