From 57899c99ead929acc48bedc84f70e67e57446b7b Mon Sep 17 00:00:00 2001 From: wanghuaz Date: Mon, 13 Dec 2010 07:33:33 +0000 Subject: [PATCH] add hfi support in dhcp and running on rhel6 git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@8390 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/anaconda.pm | 6 +++ xCAT-server/lib/xcat/plugins/dhcp.pm | 60 +++++++++++++++++++++++- 2 files changed, 64 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index 6294275ae..32c631513 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -587,6 +587,12 @@ sub mknetboot $kcmdline .= "BOOTIF=" . $mac . " "; } } + + if ( grep /hf/, $reshash->{$node}->[0]->{installnic} ) + { + $kcmdline .= "rdloaddriver=hf_if "; + } + if (defined $sent->{serialport}) { diff --git a/xCAT-server/lib/xcat/plugins/dhcp.pm b/xCAT-server/lib/xcat/plugins/dhcp.pm index c88b55062..527b4ad63 100644 --- a/xCAT-server/lib/xcat/plugins/dhcp.pm +++ b/xCAT-server/lib/xcat/plugins/dhcp.pm @@ -462,14 +462,14 @@ sub preprocess_request } if(grep /-h/,@{$req->{arg}}) { - my $usage="Usage: makedhcp -n\n\tmakedhcp -a\n\tmakedhcp -a -d\n\tmakedhcp -d noderange\n\tmakedhcp [-s statements]\n\tmakedhcp [-h|--help]"; + my $usage="Usage: makedhcp -n\n\tmakedhcp -a\n\tmakedhcp -a -d\n\tmakedhcp -d noderange\n\tmakedhcp [-s statements] [--HFI]\n\tmakedhcp [-h|--help]"; $callback->({data => [$usage]}); return; } unless (($req->{arg} and (@{$req->{arg}}>0)) or $req->{node}) { - my $usage="Usage: makedhcp -n\n\tmakedhcp -a\n\tmakedhcp -a -d\n\tmakedhcp -d noderange\n\tmakedhcp [-s statements]\n\tmakedhcp [-h|--help]"; + my $usage="Usage: makedhcp -n\n\tmakedhcp -a\n\tmakedhcp -a -d\n\tmakedhcp -d noderange\n\tmakedhcp [-s statements] [--HFI]\n\tmakedhcp [-h|--help]"; $callback->({data => [$usage]}); return; } @@ -946,6 +946,62 @@ sub process_request } } close($omshell) if ($^O ne 'aix'); + foreach my $node (@{$req->{node}}) + { + unless ($machash) + { + $callback->( + { + error => ["Unable to open mac table, it may not exist yet"], + errorcode => [1] + } + ); + return; + } + my $ent = $machash->{$node}->[0]; #tab->getNodeAttribs($node, [qw(mac)]); + unless ($ent and $ent->{mac}) + { + $callback->( + { + error => ["Unable to find mac address for $node"], + errorcode => [1] + } + ); + next; + } + my $mac = $ent->{mac}; + # Workarounds for HFI devices, omshell doesn't support HFI device type, we cannot set hfi as hardware type in dhcp lease-file. + # Replace the ethernet with hfi in lease-file if --HFI is specified. + # After omshell supports HFI devices, remove these code and add correct hardware type from omshell + if ( grep /^--HFI$/, @{$req->{arg}} ) + { + unless ( open( HOSTS,"; + my @newdata = (); + close( HOSTS ); + chomp @rawdata; + foreach my $line ( @rawdata ) { + if ( $line =~ /^(.*)ethernet $mac(.*)$/ ) { + push @newdata, "$1hfi $mac$2"; + } else { + push @newdata, $line; + } + } + + unless ( open( HOSTS,">/var/lib/dhcpd/dhcpd.leases" )) { + next; + } + for my $line (@newdata) + { + print HOSTS "$line\n"; + } + close( HOSTS ); + } + + } } writeout(); if ($restartdhcp) {