From 75a45001ab669b5bcd1c22ab7ba5e7992e42b643 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Fri, 30 May 2008 17:56:28 +0000 Subject: [PATCH] -Adjust getmacs behavior in blades to take primarynic into account git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1534 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server-2.0/lib/xcat/plugins/blade.pm | 27 ++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/xCAT-server-2.0/lib/xcat/plugins/blade.pm b/xCAT-server-2.0/lib/xcat/plugins/blade.pm index 1ecdf7327..45a8d774d 100644 --- a/xCAT-server-2.0/lib/xcat/plugins/blade.pm +++ b/xCAT-server-2.0/lib/xcat/plugins/blade.pm @@ -933,12 +933,29 @@ sub rscan_stanza { } sub getmacs { - (my $code,my $macs)=inv('mac'); + (my $code,my @macs)=inv('mac'); + my $midx=0; + my $nrtab = xCAT::Table->new('noderes'); + if ($nrtab) { + my $nent = $nrtab->getNodeAttribs($curn,['primarynic','installnic']); + if ($nent) { + my $mkey; + if (defined $nent->{installnic}) { #Prefer the install nic + $mkey="installnic"; + } elsif (defined $nent->{primarynic}) { #see if primary nic was set + $mkey="primarynic"; + } + if ($mkey) { + $nent->{$mkey} =~ /(\d+)/; + $midx=$1; + } + } + } if ($code==0) { - my @macs = split /\n/,$macs; - (my $macd,my $mac) = split (/:/,$macs[0],2); + #my @macs = split /\n/,$macs; + (my $macd,my $mac) = split (/:/,$macs[$midx],2); $mac =~ s/\s+//g; - if ($macd =~ /mac address 1/i) { + if ($macd =~ /mac address \d/i) { my $mactab = xCAT::Table->new('mac',-create=>1); $mactab->setNodeAttribs($curn,{mac=>$mac}); $mactab->close; @@ -947,7 +964,7 @@ sub getmacs { return 1,"Unable to retrieve MAC address from Management Module"; } } else { - return $code,$macs; + return $code,$macs[0]; } }