Bug fixes to discovery; add root_ip handling.
Squashed commit of the following: commitcb6f125c73Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Apr 13 20:26:59 2013 +0100 discover root_ip properly commit8228e73f5bAuthor: Oliver Gorwits <oliver@cpan.org> Date: Sat Apr 13 19:47:23 2013 +0100 better name for util package commit4546036f4fAuthor: Oliver Gorwits <oliver@cpan.org> Date: Sat Apr 13 19:23:55 2013 +0100 bug fixes in getting wireless info commit78554e5516Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Apr 13 19:07:44 2013 +0100 refactor snmp_connect to handle versions and device classes commitca9edd114aAuthor: Oliver Gorwits <oliver@cpan.org> Date: Sat Apr 13 15:23:52 2013 +0100 rename discoverall to discovernew commit1b897e4aeeAuthor: Oliver Gorwits <oliver@cpan.org> Date: Sat Apr 13 14:51:06 2013 +0100 change debug log tag for store_device commit8a5306e056Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Apr 13 14:50:10 2013 +0100 rename Discover.pm to Device.pm commit3197e38819Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Apr 13 14:48:31 2013 +0100 allow netdisco-do to do all acton
This commit is contained in:
		@@ -30,40 +30,35 @@ my $result = GetOptions(
 | 
			
		||||
  'debug|D'    => \$debug,
 | 
			
		||||
) or exit(1);
 | 
			
		||||
 | 
			
		||||
# reconfigure logging to use console
 | 
			
		||||
my $CONFIG = config();
 | 
			
		||||
$CONFIG->{logger} = 'console';
 | 
			
		||||
$CONFIG->{log} = ($debug ? 'debug' : 'info');
 | 
			
		||||
 | 
			
		||||
# reconfigure logging to force console output
 | 
			
		||||
Dancer::Logger->init('console', $CONFIG);
 | 
			
		||||
 | 
			
		||||
# check requested action
 | 
			
		||||
# get requested action
 | 
			
		||||
my $action = shift @ARGV;
 | 
			
		||||
my $PERMITTED_ACTIONS = qr/(?:discover|discover_neighbors)/;
 | 
			
		||||
 | 
			
		||||
if (!length $action) {
 | 
			
		||||
  error 'error: missing action!';
 | 
			
		||||
  exit (1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if ($action !~ m/^$PERMITTED_ACTIONS$/) {
 | 
			
		||||
  error sprintf 'error: netdisco-do cannot [%s]', $action;
 | 
			
		||||
  exit (1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if (!length $device) {
 | 
			
		||||
  error 'error: missing device!';
 | 
			
		||||
  exit (1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# create worker (placeholder object for the role methods)
 | 
			
		||||
{
 | 
			
		||||
  package MyWorker;
 | 
			
		||||
  use Moo;
 | 
			
		||||
  with 'App::Netdisco::Daemon::Worker::Poller::Discover';
 | 
			
		||||
  with 'App::Netdisco::Daemon::Worker::Poller::Device';
 | 
			
		||||
}
 | 
			
		||||
my $worker = MyWorker->new();
 | 
			
		||||
 | 
			
		||||
# belt and braces check before we go ahead
 | 
			
		||||
if (not $worker->can( $action )) {
 | 
			
		||||
  error sprintf 'error: %s is not a valid action', $action;
 | 
			
		||||
  exit (1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# static configuration for the in-memory local job queue
 | 
			
		||||
setting('plugins')->{DBIC}->{daemon} = {
 | 
			
		||||
    dsn => 'dbi:SQLite:dbname=:memory:',
 | 
			
		||||
@@ -85,12 +80,6 @@ my $job = schema('daemon')->resultset('Admin')->new_result({
 | 
			
		||||
  subaction => $extra,
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
# belt and braces check before we go ahead
 | 
			
		||||
if (not $worker->can( $action )) {
 | 
			
		||||
  error sprintf 'error: %s is not a valid action for netdisco-do', $action;
 | 
			
		||||
  exit (1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# do job
 | 
			
		||||
my ($status, $log);
 | 
			
		||||
try {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user