From e632cd7b74d82fc7ead4301335770e19f26835fe Mon Sep 17 00:00:00 2001 From: wanghuaz Date: Wed, 31 Aug 2011 10:18:43 +0000 Subject: [PATCH] Code enhancement for mac address failover git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@10403 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/FSPboot.pm | 113 ++++++++++++++++++++------------------ perl-xCAT/xCAT/PPCboot.pm | 2 +- 2 files changed, 61 insertions(+), 54 deletions(-) diff --git a/perl-xCAT/xCAT/FSPboot.pm b/perl-xCAT/xCAT/FSPboot.pm index bff368d26..e550b03e0 100644 --- a/perl-xCAT/xCAT/FSPboot.pm +++ b/perl-xCAT/xCAT/FSPboot.pm @@ -98,69 +98,76 @@ sub do_rnetboot { } } - my $mac = lc($opt->{m}); - ####################################### - # Network specified - ####################################### - $cmd.= " -s auto -d auto -m \"$mac\" -S $opt->{S} -G $opt->{G} -C $opt->{C}"; - if ( exists( $opt->{o} )) { - $cmd.= " -o"; - } + my @macs = split /\|/, $opt->{m}; + foreach my $mac ( @macs ) { + $mac = lc($mac); + ####################################### + # Network specified + ####################################### + $cmd.= " -s auto -d auto -m \"$mac\" -S $opt->{S} -G $opt->{G} -C $opt->{C}"; + if ( exists( $opt->{o} )) { + $cmd.= " -o"; + } - my %client_nethash = xCAT::DBobjUtils->getNetwkInfo( [$node] ); - if ( grep /hf/, $client_nethash{$node}{mgtifname} ) { - $cmd.= " -t hfi-ent"; - } else { - $cmd.= " -t ent"; - } + my %client_nethash = xCAT::DBobjUtils->getNetwkInfo( [$node] ); + if ( grep /hf/, $client_nethash{$node}{mgtifname} ) { + $cmd.= " -t hfi-ent"; + } else { + $cmd.= " -t ent"; + } - $pprofile = "not_use"; #lpar_netboot.expect need pprofile for p5 & p6, but for p7 ih, we don't use this attribute. - - ####################################### - # Add command options - ####################################### - $cmd.= " -f \"$name\" \"$pprofile\" \"$fsp\" $id $hcp \"$node\""; - print "cmd: $cmd\n"; - my $done = 0; - while ( $done < 2 ) { - $result = ""; - $Rc = SUCCESS; - ####################################### - # Execute command - ####################################### - print "cmd:$cmd\n"; - my $pid = open( OUTPUT, "$cmd 2>&1 |"); - $SIG{INT} = $SIG{TERM} = sub { #prepare to process job termination and propogate it down - kill 9, $pid; - return( [RC_ERROR,"Received INT or TERM signal"] ); - }; - if ( !$pid ) { - return( [RC_ERROR,"$cmd fork error: $!"] ); - } - ####################################### - # Get command output - ####################################### - while ( ) { - $result.=$_; - } - close OUTPUT; + $pprofile = "not_use"; #lpar_netboot.expect need pprofile for p5 & p6, but for p7 ih, we don't use this attribute. ####################################### - # Get command exit code + # Add command options ####################################### + $cmd.= " -f \"$name\" \"$pprofile\" \"$fsp\" $id $hcp \"$node\""; + print "cmd: $cmd\n"; + my $done = 0; + while ( $done < 2 ) { + $result = ""; + $Rc = SUCCESS; + ####################################### + # Execute command + ####################################### + print "cmd:$cmd\n"; + my $pid = open( OUTPUT, "$cmd 2>&1 |"); + $SIG{INT} = $SIG{TERM} = sub { #prepare to process job termination and propogate it down + kill 9, $pid; + return( [RC_ERROR,"Received INT or TERM signal"] ); + }; + if ( !$pid ) { + return( [RC_ERROR,"$cmd fork error: $!"] ); + } + ####################################### + # Get command output + ####################################### + while ( ) { + $result.=$_; + } + close OUTPUT; + + ####################################### + # Get command exit code + ####################################### - foreach ( split /\n/, $result ) { - if ( /^lpar_netboot / ) { - $Rc = RC_ERROR; - last; + foreach ( split /\n/, $result ) { + if ( /^lpar_netboot / ) { + $Rc = RC_ERROR; + last; + } + } + + if ( $Rc == SUCCESS ) { + $done = 2; + } else { + $done = $done + 1; + sleep 1; } } if ( $Rc == SUCCESS ) { - $done = 2; - } else { - $done = $done + 1; - sleep 1; + last; } } return( [$Rc,$result] ); diff --git a/perl-xCAT/xCAT/PPCboot.pm b/perl-xCAT/xCAT/PPCboot.pm index 5fb3d923a..3b1cdf417 100644 --- a/perl-xCAT/xCAT/PPCboot.pm +++ b/perl-xCAT/xCAT/PPCboot.pm @@ -182,7 +182,7 @@ sub do_rnetboot { $cmd.= " -o"; } - my @macs = split /,/, $opt->{m}; + my @macs = split /\|/, $opt->{m}; foreach my $mac ( @macs ) { ####################################### # Network specified