From cb0f4d3e34ba2fc8a642189f9ed9f87407cd84d5 Mon Sep 17 00:00:00 2001 From: sakolish <sakolish@8638fb3e-16cb-4fca-ae20-7b5d299a9bcd> Date: Fri, 15 Feb 2008 15:24:37 +0000 Subject: [PATCH] Changed format_xml() output format - Line #470 git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@490 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT-2.0/xCAT/PPCscan.pm | 45 ++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/perl-xCAT-2.0/xCAT/PPCscan.pm b/perl-xCAT-2.0/xCAT/PPCscan.pm index b6eb3ade3..cd1baaaac 100644 --- a/perl-xCAT-2.0/xCAT/PPCscan.pm +++ b/perl-xCAT-2.0/xCAT/PPCscan.pm @@ -21,6 +21,13 @@ my @header = ( ["serial-number", "%-15s" ], ["address", "%s\n" ]); +my @attribs = qw(nodetype name id model serial hcp profile parent groups mgt); +my %nodetype = ( + fsp => $::NODETYPE_FSP, + bpa => $::NODETYPE_BPA, + lpar =>"$::NODETYPE_LPAR,$::NODETYPE_OSI" +); + ########################################################################## # Parse the command line for options and operands @@ -352,7 +359,7 @@ sub format_output { # -x flag for xml format ########################################### if ( exists( $opt->{x} )) { - $result = format_xml( $values ); + $result = format_xml( $hwtype, $values ); } ########################################### # -z flag for stanza format @@ -415,12 +422,6 @@ sub format_stanza { my $hwtype = shift; my $values = shift; my $result; - my @attribs = qw(nodetype name id model serial hcp profile parent groups mgt); - my %nodetype = ( - fsp => $::NODETYPE_FSP, - bpa => $::NODETYPE_BPA, - lpar =>"$::NODETYPE_LPAR,$::NODETYPE_OSI" - ); ##################################### # Skip hardware control point @@ -468,14 +469,21 @@ sub format_stanza { ########################################################################## sub format_xml { + my $hwtype = shift; my $values = shift; my $xml; + ##################################### + # Skip hardware control point + ##################################### + shift(@$values); + ##################################### # Create XML formatted attributes ##################################### foreach ( @$values ) { my @data = split /,/; + my $type = $data[0]; my $i = 0; ################################# @@ -487,19 +495,23 @@ sub format_xml { ################################# # Add each attribute ################################# - foreach ( @header ) { + foreach ( @attribs ) { my $d = $data[$i++]; - ############################# - # Use IPs instead of - # hardware control address - ############################# - if ( @$_[0] eq "address" ) { - if ( $data[0] !~ /^hmc|ivm$/ ) { - $d = $data[8]; + if ( /^name$/ ) { + next; + } elsif ( /^nodetype$/ ) { + $d = $nodetype{$d}; + } elsif ( /^groups$/ ) { + $d = "$hwtype,all"; + } elsif ( /^mgt$/ ) { + $d = $hwtype; + } elsif ( /^model|serial$/ ) { + if ( $type eq "lpar" ) { + $d = undef; } } - $href->{Node}->{@$_[0]} = $d; + $href->{Node}->{$_} = $d; } ################################# # XML encoding @@ -547,3 +559,4 @@ sub rscan { +