[freeside-commits] freeside/FS/FS/NetworkMonitoringSystem Torrus_Internal.pm, 1.7, 1.8

Ivan,,, ivan at wavetail.420.am
Fri Feb 25 17:44:12 PST 2011


Update of /home/cvs/cvsroot/freeside/FS/FS/NetworkMonitoringSystem
In directory wavetail.420.am:/tmp/cvs-serv573

Modified Files:
	Torrus_Internal.pm 
Log Message:
fix newlines in interface addition, throw some sort of error for duplicate addition, RT#10574

Index: Torrus_Internal.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/NetworkMonitoringSystem/Torrus_Internal.pm,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -w -d -r1.7 -r1.8
--- Torrus_Internal.pm	10 Feb 2011 01:08:44 -0000	1.7
+++ Torrus_Internal.pm	26 Feb 2011 01:44:10 -0000	1.8
@@ -132,9 +132,13 @@
 
   #should just use a proper XML parser huh
 
+  my @ddx = split(/\n/, $self->_torrus_loadddx);
+
+  die "Torrus Service ID $serviceid in use\n"
+    if grep /^\s*$serviceid:/, @ddx;
+
   my $newline = "     $serviceid:$interface:Both:main,";
 
-  my @ddx = split(/\n/, $self->_torrus_loadddx);
   my $new = '';
 
   my $added = 0;
@@ -149,10 +153,10 @@
 
         while ( my $paramline = shift(@ddx) ) {
           if ( $paramline =~ /^\s*<\/param>/ ) {
-            $new .= "$newline\n$paramline";
+            $new .= "$newline\n$paramline\n";
             last; #paramline
           } else {
-            $new .= $paramline;
+            $new .= "$paramline\n";
           }
         }
 
@@ -165,7 +169,7 @@
             qq(     $newline\n").
             qq(   </param>\n);
         }
-        $new .= $hostline;
+        $new .= "$hostline\n";
         last; #hostline
       }
  
@@ -212,7 +216,7 @@
 sub _torrus_reload {
   my($self) = @_;
 
-  #i should have better error checking
+  #i should use IPC::Run and have better error checking
 
   system('torrus', 'devdiscover', "--in=$ddxfile");
 



More information about the freeside-commits mailing list