From 5d4003fcc9e35e82e2000bdb6b5df50af06345d1 Mon Sep 17 00:00:00 2001 From: zhanx Date: Fri, 13 Feb 2009 09:42:26 +0000 Subject: [PATCH] Make mkvm support lhea (increment lhea logical port numbers based the lpar specified) git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@2741 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/PPCvm.pm | 43 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/perl-xCAT/xCAT/PPCvm.pm b/perl-xCAT/xCAT/PPCvm.pm index a14b0aa09..32a979c89 100644 --- a/perl-xCAT/xCAT/PPCvm.pm +++ b/perl-xCAT/xCAT/PPCvm.pm @@ -869,6 +869,41 @@ sub list { +########################################################################## +# Increments virtual lhea adapter in partition profile +########################################################################## +sub lhea_adapter { + + my $cfgdata = shift; + + ######################################### + # Increment LHEA adapters if present + # 23000000/2/1/7/none,23000008/2/1/4/none + # Increment 7 and 4 in example above. + ######################################### + if ( $cfgdata =~ /(\"*lhea_logical_ports)/ ) { + + ##################################### + # If double-quoted, has comma- + # seperated list of adapters + ##################################### + my $delim = ( $1 =~ /^\"/ ) ? "\\\\\"" : ","; + $cfgdata =~ /lhea_logical_ports=([^$delim]+)|$/; + + my @lhea = split ",", $1; + foreach ( @lhea ) { + if ( /(\w+)\/(\w+)$/ ) { + my $id = ($1 =~ /(\d+)/) ? $1+1 : $1; + s/(\w+)\/(\w+)$/$id\/$2/; + } + } + my $adapters = "lhea_logical_ports=".join( ",", @lhea ); + $cfgdata =~ s/lhea_logical_ports=[^$delim]+/$adapters/; + } + return( $cfgdata ); +} + + ########################################################################## # Increments virtual scsi adapter in partition profile ########################################################################## @@ -1008,6 +1043,14 @@ sub create { $cfgdata =~ s/\blpar_id=[^,]+|$/lpar_id=$id/; $cfgdata =~ s/\bname=[^,]+|$/name=$name/; + ################################# + # Modify LHEA adapters + ################################# + if ( $cfgdata =~ /lhea_logical_ports=(\w+)/ ) { + if ( $1 !~ /^none$/i ) { + $cfgdata = lhea_adapter( $cfgdata ); + } + } ################################# # Modify SCSI adapters #################################