You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vcl.apache.org by ar...@apache.org on 2011/08/15 15:27:04 UTC

svn commit: r1157836 - /incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm

Author: arkurth
Date: Mon Aug 15 13:27:04 2011
New Revision: 1157836

URL: http://svn.apache.org/viewvc?rev=1157836&view=rev
Log:
VCL-384
Updated Linux.pm::enable_dhcp to remove any Windows-style carriage returns from the ifcfg-eth* files when they are recreated. Added code to delete the dhclient lease files to correct a problem where the computer would attempt to ping its old address when it came up, and then disable the interface.

Modified:
    incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm

Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm?rev=1157836&r1=1157835&r2=1157836&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm (original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm Mon Aug 15 13:27:04 2011
@@ -2994,7 +2994,6 @@ sub enable_dhcp {
 	}
 	
 	for my $interface_name (@interface_names) {
-print "\n\n" . '-' x 100 . "\n\n";
 		my $ifcfg_file_path = "/etc/sysconfig/network-scripts/ifcfg-$interface_name";
 		notify($ERRORS{'DEBUG'}, 0, "attempting to enable DHCP on interface: $interface_name\nifcfg file path: $ifcfg_file_path");
 		
@@ -3004,12 +3003,15 @@ BOOTPROTO=dhcp
 ONBOOT=yes
 EOF
 		
+		# Remove any Windows carriage returns
+		$ifcfg_file_contents =~ s/\r//g;
+		
 		# Remove the last newline
 		$ifcfg_file_contents =~ s/\n$//s;
 		
 		# Write the contents to the ifcfg file
 		if ($self->create_text_file($ifcfg_file_path, $ifcfg_file_contents)) {
-			notify($ERRORS{'DEBUG'}, 0, "updated $ifcfg_file_path:\n$ifcfg_file_contents");
+			notify($ERRORS{'DEBUG'}, 0, "updated $ifcfg_file_path:\n" . string_to_ascii($ifcfg_file_contents));
 		}
 		else {
 			notify($ERRORS{'WARNING'}, 0, "failed to update $ifcfg_file_path");
@@ -3018,6 +3020,9 @@ EOF
 		
 		# Remove any leftover ifcfg-*.bak files
 		$self->delete_file('/etc/sysconfig/network-scripts/ifcfg-eth*.bak');
+		
+		# Remove dhclient lease files
+		$self->delete_file('/var/lib/dhclient/*.leases');
 	}
 	
 	return 1;