From e130863d821119f37bb612e36ce8e71246510346 Mon Sep 17 00:00:00 2001 From: ligc Date: Tue, 7 Sep 2010 07:38:03 +0000 Subject: [PATCH] fix for bug 3060242: chvm supports "cat vmdef | chvm nodename" git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@7368 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/PPCvm.pm | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/perl-xCAT/xCAT/PPCvm.pm b/perl-xCAT/xCAT/PPCvm.pm index 7beacc1b9..5c57552b0 100644 --- a/perl-xCAT/xCAT/PPCvm.pm +++ b/perl-xCAT/xCAT/PPCvm.pm @@ -793,6 +793,42 @@ sub modify_by_attr { my $attrstr= $opt->{a}; my @values; + # attrstr will be in stdin for "cat vmdef | chvm nodename" + if (!defined($attrstr) && defined($request->{stdin})) { + my $tempattr = $request->{stdin}; + $tempattr =~ s/\s+$//; + $tempattr =~ s/^[\w]+: //; + my $newcfg = strip_profile( $tempattr, $hwtype ); + $newcfg =~ s/,*lpar_env=[^,]+|$//; + $newcfg =~ s/,*all_resources=[^,]+|$//; + $newcfg =~ s/,*lpar_name=[^,]+|$//; + $newcfg =~ s/\\\"/\"/g; + my @cfgarray = split /,/, $newcfg; + ########################################## + # Repair those lines splitted incorrectly + ########################################## + my @newcfgarray; + my $full_line; + while (my $line = shift( @cfgarray)) + { + if ( !$full_line) + { + $full_line = $line; + } + else + { + $full_line = "$full_line,$line"; + } + if ( $full_line =~ /^[^\"]/ or $full_line =~ /^\".+\"$/) + { + $full_line =~ s/^\"(.+)\"$/$1/; + push @newcfgarray, $full_line; + $full_line = undef; + next; + } + } + $attrstr = \@newcfgarray; + } if ( defined( $attrstr )) { ################################### # Get LPAR active profiles