From 4b5d163973911bf2efc553e76b14a8cc48dfe498 Mon Sep 17 00:00:00 2001 From: sakolish Date: Thu, 29 May 2008 19:01:07 +0000 Subject: [PATCH] Fixed rscan stanza/xml formatting for use in "mkdef" input git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1524 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server-2.0/lib/xcat/plugins/blade.pm | 53 +++++++++++++++++------ 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/xCAT-server-2.0/lib/xcat/plugins/blade.pm b/xCAT-server-2.0/lib/xcat/plugins/blade.pm index 95360f982..1ecdf7327 100644 --- a/xCAT-server-2.0/lib/xcat/plugins/blade.pm +++ b/xCAT-server-2.0/lib/xcat/plugins/blade.pm @@ -151,6 +151,7 @@ my %bootnumbers = ( 'usb' => 11 ); +my @rscan_attribs = qw(nodetype name id mtm serial mpa groups mgt); my @rscan_header = ( ["type", "%-8s" ], ["name", "" ], @@ -803,10 +804,10 @@ sub rscan { $rscan_header[1][1] = $format; if (exists($opt{x})) { - $result = rscan_xml(\@values); + $result = rscan_xml($mpa,\@values); } elsif ( exists( $opt{z} )) { - $result = rscan_stanza( \@values ); + $result = rscan_stanza($mpa,\@values); } else { foreach ( @rscan_header ) { @@ -866,6 +867,7 @@ sub rscan { sub rscan_xml { + my $mpa = shift; my $values = shift; my $xml; @@ -876,30 +878,55 @@ sub rscan_xml { my $href = { Node => { } }; - foreach (@rscan_header) { - $href->{Node}->{@$_[0]} = $data[$i++]; + foreach ( @rscan_attribs ) { + my $d = $data[$i++]; + my $type = $data[0]; + + if ( /^name$/ ) { + next; + } elsif ( /^nodetype$/ ) { + $d = $type; + } elsif ( /^groups$/ ) { + $d = "$type,all"; + } elsif ( /^mgt$/ ) { + $d = "blade"; + } elsif ( /^mpa$/ ) { + $d = $mpa; + } + $href->{Node}->{$_} = $d; } $xml.= XMLout($href,NoAttr=>1,KeyAttr=>[],RootName=>undef); } return( $xml ); } - sub rscan_stanza { - + + my $mpa = shift; my $values = shift; my $result; - + foreach (@$values) { my @data = split /,/; - my $i = 0; + my $i = 0; + my $type = $data[0]; $result .= "$data[1]:\n\tobjtype=node\n"; - foreach ( @rscan_header ) { - if ( @$_[0] ne "name" ) { - $result .= "\t@$_[0]=$data[$i]\n"; - } - $i++; + foreach ( @rscan_attribs ) { + my $d = $data[$i++]; + + if ( /^name$/ ) { + next; + } elsif ( /^nodetype$/ ) { + $d = $type; + } elsif ( /^groups$/ ) { + $d = "$type,all"; + } elsif ( /^mgt$/ ) { + $d = "blade"; + } elsif ( /^mpa$/ ) { + $d = $mpa; + } + $result .= "\t$_=$d\n"; } } return( $result );