[freeside-commits] freeside/FS/FS/NetworkMonitoringSystem Torrus_Internal.pm, 1.18.2.2, 1.18.2.3
Ivan,,,
ivan at wavetail.420.am
Sun Dec 18 17:27:19 PST 2011
Update of /home/cvs/cvsroot/freeside/FS/FS/NetworkMonitoringSystem
In directory wavetail.420.am:/tmp/cvs-serv19949/NetworkMonitoringSystem
Modified Files:
Tag: FREESIDE_2_3_BRANCH
Torrus_Internal.pm
Log Message:
missing commit from nms auto-addition fixes, RT#15536
Index: Torrus_Internal.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/NetworkMonitoringSystem/Torrus_Internal.pm,v
retrieving revision 1.18.2.2
retrieving revision 1.18.2.3
diff -u -w -d -r1.18.2.2 -r1.18.2.3
--- Torrus_Internal.pm 26 Oct 2011 02:44:18 -0000 1.18.2.2
+++ Torrus_Internal.pm 19 Dec 2011 01:27:17 -0000 1.18.2.3
@@ -5,6 +5,7 @@
use Fcntl qw(:flock);
use IO::File;
use File::Slurp qw(slurp);
+use IPC::Run qw(run);
use Date::Format;
use XML::Simple;
use FS::Record qw(qsearch qsearchs dbh);
@@ -154,11 +155,18 @@
}
+sub queued_add_router {
+ my $self = shift;
+ my $error = $self->add_router(@_);
+ die $error if $error;
+}
+
sub add_router {
my($self, $ip, $community) = @_;
- $community = qq!<param name="snmp-community" value="$community"/>\n !
- if length($community) > 1;
+ $community = (defined($community) && length($community) > 1)
+ ? qq!<param name="snmp-community" value="$community"/>\n !
+ : '';
my $newhost =
qq( <host>\n).
@@ -257,23 +265,31 @@
close $new;
my $tmpname = $ddxfile . Date::Format::time2str('%Y%m%d%H%M%S',time);
- rename("$ddxfile", $tmpname) or die $!;
+ rename($ddxfile, $tmpname) or die $!;
rename("$ddxfile.new", $ddxfile) or die $!;
- $self->_torrus_reload;
+ my $error = $self->_torrus_reload;
+ if ( $error ) { #revert routers.ddx
+ rename($ddxfile, "$tmpname.FAILED") or die $!;
+ rename($tmpname, $ddxfile) or die $!;
+ }
+
+ $self->_torrus_unlock;
+
+ return $error;
}
sub _torrus_reload {
my($self) = @_;
- #i should use IPC::Run and have better error checking (commands are silent
- # for success, or output errors)
-
- system('torrus', 'devdiscover', "--in=$ddxfile");
+ my $stderr = '';
+ run( ['torrus', 'devdiscover', "--in=$ddxfile"], '2>'=>\$stderr );
+ return $stderr if $stderr;
- system('torrus', 'compile', '--tree=main'); # , '--verbose'
+ run( ['torrus', 'compile', '--tree=main'] ); # , '--verbose'
+ #typically the errors happen at the discover stage...
- $self->_torrus_unlock;
+ '';
}
More information about the freeside-commits
mailing list