From 648fb472e3d52b5cefa8f703e9d650498721eaf8 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Fri, 26 Jun 2009 19:29:01 +0000 Subject: [PATCH] -Create xNBA bootstrap config files for nbfs git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3652 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Utils.pm | 21 ++++++++++++++++ xCAT-server/lib/xcat/plugins/mknb.pm | 37 ++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index d6834e2fd..08253b434 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -1829,6 +1829,27 @@ sub my_hexnets return $rethash; } +sub my_nets +{ + my $rethash; + my @nets = split /\n/, `/sbin/ip addr`; #could use ip route, but to match hexnets... + foreach (@nets) + { + my @elems = split /\s+/; + unless (/^\s*inet\s/) + { + next; + } + (my $curnet, my $maskbits) = split /\//, $elems[2]; + my $curmask = 2**$maskbits - 1 << (32 - $maskbits); + my $nown = unpack("N", inet_aton($curnet)); + $nown = $nown & $curmask; + my $textnet=inet_ntoa(pack("N",$nown)); + $textnet.="/$maskbits"; + $rethash->{$textnet} = $curnet; + } + return $rethash; +} #------------------------------------------------------------------------------- =head3 my_if_netmap diff --git a/xCAT-server/lib/xcat/plugins/mknb.pm b/xCAT-server/lib/xcat/plugins/mknb.pm index ddd510043..599c9e788 100644 --- a/xCAT-server/lib/xcat/plugins/mknb.pm +++ b/xCAT-server/lib/xcat/plugins/mknb.pm @@ -95,6 +95,7 @@ sub process_request { system("cd $tempdir; find . | cpio -o -H newc | gzip -9 > $tftpdir/xcat/nbfs.$arch.gz"); system ("rm -rf $tempdir"); my $hexnets = xCAT::Utils->my_hexnets(); + my $normnets = xCAT::Utils->my_nets(); my $consolecmdline; if (defined($serialport) and $serialspeed) { $consolecmdline = "console=ttyS$serialport,$serialspeed"; @@ -104,6 +105,8 @@ sub process_request { } my $cfgfile; if ($arch =~ /x86/) { + mkpath("$tftpdir/xcat/xnba/nets"); + chmod(0755,"$tftpdir/xcat/xnba"); mkpath("$tftpdir/pxelinux.cfg"); chmod(0755,"$tftpdir/pxelinux.cfg"); if (! -r "$tftpdir/pxelinux.0") { @@ -125,6 +128,40 @@ sub process_request { } } my $dopxe=0; + foreach (keys %{$normnets}) { + my $net = $_; + $net =~s/\//_/; + $dopxe=0; + if ($arch =~ /x86/) { #only do pxe if just x86 or x86_64 and no x86 + if ($arch =~ /x86_64/) { + if (-r "$tftpdir/xcat/xnba/$_.net") { + my $cfg; + my @contents; + open($cfg,"<","$tftpdir/xcat/xnba/nets/$net"); + @contents = <$cfg>; + close($cfg); + if (grep (/x86_64/,@contents)) { + $dopxe=1; + } + } else { + $dopxe = 1; + } + } else { + $dopxe = 1; + } + } + if ($dopxe) { + my $cfg; + open($cfg,">","$tftpdir/xcat/xnba/nets/$net"); + print $cfg "#!gpxe\n"; + print $cfg 'imgfetch -n kernel tftp://${next-server}/xcat/nbk.'."$arch quiet xcatd=".$normnets->{$_}.":$xcatdport $consolecmdline\n"; + print $cfg 'imgfetch -n nbfs tftp://${next-server}/xcat/nbfs.'."$arch.gz\n"; + print $cfg "imgload kernel\n"; + print $cfg "imgexec kernel\n"; + close($cfg); + } + } + $dopxe=0; foreach (keys %{$hexnets}) { $dopxe=0; if ($arch =~ /x86/) { #only do pxe if just x86 or x86_64 and no x86