version 1.33, 2007/02/07 22:07:35 |
version 1.34, 2007/02/07 23:24:39 |
|
|
#!/usr/bin/perl |
#!/usr/bin/perl |
# $RedRiver: update_trango.pl,v 1.32 2007/02/07 19:25:05 andrew Exp $ |
# $RedRiver: update_trango.pl,v 1.33 2007/02/07 22:07:35 andrew Exp $ |
######################################################################## |
######################################################################## |
# update_trango.pl *** Updates trango hosts with a new firmware |
# update_trango.pl *** Updates trango hosts with a new firmware |
# |
# |
|
|
$host->{retry}--; |
$host->{retry}--; |
} |
} |
else { |
else { |
$l->sp("Failed"); |
$l->sp("Failed! - Bye $host->{name}"); |
|
$l->e("Error updating $firmware_type on $host->{name}" . |
|
"(try $host->{tries})"); |
$t->bye; |
$t->bye; |
next; |
# don't try any other firmware, don't want to reboot |
|
last; |
} |
} |
|
|
} |
} |
|
|
#use YAML; |
#use YAML; |
use constant LOG_PRINT => 128; |
use constant LOG_PRINT => 128; |
use constant LOG_SAVE => 64; |
use constant LOG_SAVE => 64; |
|
use constant LOG_ERR => 1; |
|
|
DESTROY { |
DESTROY { |
my $self = shift; |
my $self = shift; |
|
|
return $self->mylog( $m, LOG_SAVE | LOG_PRINT ); |
return $self->mylog( $m, LOG_SAVE | LOG_PRINT ); |
} |
} |
|
|
|
sub e { |
|
my $self = shift; |
|
my $m = shift; |
|
return $self->mylog( $m, LOG_ERR ); |
|
} |
|
|
sub mylog { |
sub mylog { |
my $self = shift; |
my $self = shift; |
|
|
|
|
print $MYLOG ( scalar gmtime ), "\t", $thing, "\n" |
print $MYLOG ( scalar gmtime ), "\t", $thing, "\n" |
or die "Couldn't print to MYLOG: $!"; |
or die "Couldn't print to MYLOG: $!"; |
flock( $MYLOG, LOCK_UN ); |
flock( $MYLOG, LOCK_UN ); |
|
} |
|
|
|
if ( $which & LOG_ERR ) { |
|
# XXX Could tie in here to handle some sort of notifications. |
|
print STDERR $thing, "\n"; |
} |
} |
} |
} |
|
|