--- mdap-server.pl 2007/11/16 14:59:30 47 +++ mdap-server.pl 2007/11/18 00:55:43 64 @@ -7,16 +7,18 @@ use Getopt::Long; use lib './lib'; -use MDAP::ChangeIP; +use MDAP; my $GROUP = '224.0.0.103'; my $PORT = '3235'; -my $debug = 0; +#my $debug = 0; # from MDAP my $quiet = 1; my $verbose = 0; my $credentials = 0; +my $plugins = 1; + my $resend_search_delay = 3; my $tftp_path = '/srv/tftp/'; @@ -32,6 +34,7 @@ "tftp=s" => \$tftp_path, "credentials" => \$credentials, "exec=s" => \$flashed_cmd, + 'plugins!' => \$plugins, ); $quiet = 0 if $verbose; @@ -159,14 +162,6 @@ delete $ant_ok_password->{$ant}; } -my $once; - -sub once { - my $m = join('', @_); - $once->{$m}++; - print $m if ($once->{$m} == 1); -} - my $status = ''; sub status { @@ -243,8 +238,7 @@ once "$ant OK version $build", $ant_unknown_password->{$ant} ? ' with unknown password' : $ant_passwd->{$ant} ? ' password protected' : - '', - "\n"; + ''; $ant_flashing->{$ant} = 0; # green|red|orange|flash|off @@ -262,22 +256,34 @@ status "$waiting of $count ants still flasing upto $build\n"; } } - } else { - once "!! NO FIRMWARE for $board in $tftp_path for ant $ant, skipping update\n"; - } - if ( my $command = CWMP::ChangeIP::check( $h ) ) { - warn "## sending $command to $ant\n"; - mdap_send("EXEC-CLI MDAP/$mdap_ver\r\nCLI-CMD:$command\r\nSEQ-NR:1\r\nTO-ANT:$ant\r\nUSER-ID:$user_id\r\nUSER-PWD:$user_pwd\r\n"); + if ( $plugins ) { + foreach my $plugin ( MDAP->plugins ) { + warn "## calling $plugin\n" if $debug; + if ( my $command = $plugin->check( $h ) ) { + + warn ">> $plugin $ant ", + $h->{'ANT-NAME'}, " ", + $h->{'_BUILD'}, " ", + "\t:$command\n"; + + mdap_send("EXEC-CLI MDAP/$mdap_ver\r\nCLI-CMD:$command\r\nSEQ-NR:1\r\nTO-ANT:$ant\r\nUSER-ID:$user_id\r\nUSER-PWD:$user_pwd\r\n"); + last; + } + } + } + + } else { + once "!! NO FIRMWARE for $board in $tftp_path for ant $ant, skipping update"; } } elsif ( $type eq 'REPLY-EXEC-CLI' ) { - print "+ $type\n$data\n" if ($verbose); + print "##<< $type\n$data\n" if $debug; if ( $seq_nr == 1 ) { mdap_send("EXEC-CLI MDAP/$mdap_ver\r\nSEQ-NR:2\r\nTO-ANT:$ant\r\nUSER-ID:$user_id\r\nUSER-PWD:$user_pwd\r\n"); forget_ant( $ant ) if ( $ant_flashing->{$ant} ); } elsif ( $seq_nr < 0 ) { - warn "EXEC-CLI failed\n"; + warn "EXEC-CLI failed: $data\n"; } } else {