From 193cb671ef944df6836f71c96de97250768f3e0f Mon Sep 17 00:00:00 2001 From: mxi1 Date: Thu, 26 Mar 2009 05:28:38 +0000 Subject: [PATCH] Fixed bug#2689644 �, "makedhcp -n" will update /etc/sysconfig/dhcpd according to the netowrks table git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@2994 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/dhcp.pm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/dhcp.pm b/xCAT-server/lib/xcat/plugins/dhcp.pm index 1b137f9a0..302c05f6f 100644 --- a/xCAT-server/lib/xcat/plugins/dhcp.pm +++ b/xCAT-server/lib/xcat/plugins/dhcp.pm @@ -402,6 +402,31 @@ sub process_request if (grep /^-n$/, @{$req->{arg}}) { + #support for /etc/sysconfig/dhcpd + if(-e "/etc/sysconfig/dhcpd") { + my @dhcpdifs = split / /,`grep '^DHCPD_INTERFACE' /etc/sysconfig/dhcpd |sed -e 's/DHCPD_INTERFACE=\"//' |sed -e 's/\"//'`; + if(scalar @dhcpdifs > 0) { + chomp $dhcpdifs[scalar @dhcpdifs - 1]; + } + #get "mgtifname" from network table + my $nettab = xCAT::Table->new("networks"); + my @nets_ref = $nettab->getAllAttribs('net','mgtifname'); + + foreach(@nets_ref) { + my $if = $_->{mgtifname}; + #add the neccessary mgtifnames to @dhcpifs + my $num = grep /$if/, @dhcpdifs; + next if ($num > 0); + push @dhcpdifs, $if; + } + + #update DHCPINTERFACES in the file /etc/sysconfig/dhcpd + my @tmp = map {"$_ "} @dhcpdifs; + my $output = `sed 's/^DHCPD_INTERFACE=.*$\"/DHCPD_INTERFACE=\"@tmp\"/' /etc/sysconfig/dhcpd`; + open DHCPD_FD, '>', "/etc/sysconfig/dhcpd"; + print DHCPD_FD $output; + close DHCPD_FD; + } if (-e "/etc/dhcpd.conf") { my $bakname = "/etc/dhcpd.conf.xcatbak";