use %activenics to config /etc/sysconfig/dhcpd
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3019 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
8658635a96
commit
74e5cf6e40
@ -423,31 +423,6 @@ 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";
|
||||
@ -507,6 +482,44 @@ sub process_request
|
||||
}
|
||||
}
|
||||
}
|
||||
#add the active nics to /etc/sysconfig/dhcpd
|
||||
if (-e "/etc/sysconfig/dhcpd") {
|
||||
open DHCPD_FD, "/etc/sysconfig/dhcpd";
|
||||
my $syscfg_dhcpd = "";
|
||||
my $found = 0;
|
||||
my $dhcpd_key = "DHCPDARGS";
|
||||
my $os = xCAT::Utils->osver();
|
||||
if ($os =~ /sles/i) {
|
||||
$dhcpd_key = "DHCPD_INTERFACE";
|
||||
}
|
||||
|
||||
my $ifarg = "$dhcpd_key=\"";
|
||||
foreach (keys %activenics) {
|
||||
$ifarg .= " $_";
|
||||
}
|
||||
$ifarg .= "\"\n";
|
||||
|
||||
while (<DHCPD_FD>) {
|
||||
if ($_ =~ m/^$dhcpd_key/) {
|
||||
$found = 1;
|
||||
$syscfg_dhcpd .= $ifarg;
|
||||
}else {
|
||||
$syscfg_dhcpd .= $_;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $found eq 0 ) {
|
||||
$syscfg_dhcpd .= $ifarg;
|
||||
}
|
||||
close DHCPD_FD;
|
||||
|
||||
open DBG_FD, '>', "/etc/sysconfig/dhcpd";
|
||||
print DBG_FD $syscfg_dhcpd;
|
||||
close DBG_FD;
|
||||
} else {
|
||||
$callback->({error=>"The file /etc/sysconfig/dhcpd doesn't exist, check the dhcp server"});
|
||||
return;
|
||||
}
|
||||
unless ($dhcpconf[0])
|
||||
{ #populate an empty config with some starter data...
|
||||
$restartdhcp=1;
|
||||
|
Loading…
Reference in New Issue
Block a user