1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
#!/usr/bin/perl
# IBM_PROLOG_BEGIN_TAG
# This is an automatically generated prolog.
#
# $Source: src/usr/targeting/common/genNodeMrwXml.pl $
#
# IBM CONFIDENTIAL
#
# COPYRIGHT International Business Machines Corp. 2013
#
# p1
#
# Object Code Only (OCO) source materials
# Licensed Internal Code Source Materials
# IBM HostBoot Licensed Internal Code
#
# The source code for this program is not published or otherwise
# divested of its trade secrets, irrespective of what has been
# deposited with the U.S. Copyright Office.
#
# Origin: 30
#
# IBM_PROLOG_END_TAG
#
# Usage:
#
# genNodeMrwXml.pl --system=systemname --mrwdir=pathname
# --build=hb/fsp --nodeCount=nodeCount
# [--help]
#
# --system=systemname
# Specify which system MRW XML to be generated.
# The file name will be set as uppercase
# --mrwdir=pathname
# Specify the complete dir pathname of the MRW.
# --build=hb/fsp
# Specify if HostBoot build (hb) or FSP build (fsp)
# --nodeCount
# Specify the max number of nodes for the system
# --help
# displays usage
#
# Purpose:
#
# This perl script processes the various xml files of the Tuleta MRW to
# extract the needed information for generating the final xml file.
#
use strict;
use XML::Simple;
use Data::Dumper;
################################################################################
# Set PREFERRED_PARSER to XML::Parser. Otherwise it uses XML::SAX which contains
# bugs that result in XML parse errors that can be fixed by adjusting white-
# space (i.e. parse errors that do not make sense).
################################################################################
$XML::Simple::PREFERRED_PARSER = 'XML::Parser';
################################################################################
#main
################################################################################
my $mrwdir = "";
my $sysname = "";
my $usage = 0;
my $nodeCount = 0;
my $build = "fsp";
use Getopt::Long;
GetOptions( "mrwdir:s" => \$mrwdir,
"system:s" => \$sysname,
"nodeCount:i" => \$nodeCount,
"build:s" => \$build,
"help" => \$usage, );
if ($usage || ($mrwdir eq "") || ($sysname eq ""))
{
display_help();
exit 0;
}
if ($nodeCount ==0)
{
#no nodes so don't need to create node xml files
exit 0;
}
my $SYSNAME = uc($sysname);
my $outFile = "";
my @nodeOutFiles;
my $sysInfo;
my $fileSuffix;
if ($build eq "fsp")
{
$fileSuffix="fsp";
}
elsif ($build eq "hb")
{
$fileSuffix="hb";
}
else
{
die "ERROR: $build is not valid. Valid values are fsp or hb\n";
}
#create files
open (FH, "<$mrwdir/${SYSNAME}_${fileSuffix}.mrw.xml") ||
die "ERROR: unable to open $mrwdir/${SYSNAME}_${fileSuffix}.mrw.xml\n";
close (FH);
$sysInfo = XMLin("$mrwdir/${SYSNAME}_${fileSuffix}.mrw.xml",
ForceArray=>1);
#print Dumper($sysInfo);
for my $j(0..($nodeCount))
{
$outFile = "$mrwdir/${SYSNAME}_node_$j"."_${fileSuffix}.mrw.xml";
push @nodeOutFiles, [$outFile];
}
#create file discriptor array
my @nodeFD;
for my $k(0..$#nodeOutFiles)
{
my $filename= sprintf("%s",@{$nodeOutFiles[$k]});
open $nodeFD[$k], '>', $filename ||
die "ERROR: unable to create $filename\n";
}
#read in the targeting data from system xml files
foreach my $targetInstance (@{$sysInfo->{targetInstance}})
{
my $Id = $targetInstance->{'id'};
my $targetId = sprintf("%s",@{$Id});
#print("targetId =", $targetId, "\n");
my $xmlData= XMLout($targetInstance,RootName => "targetInstance");
#print Dumper($xmlData);
if ($targetId eq "sys0")
{
for my $node(0..$nodeCount)
{
print {$nodeFD[$node]} $xmlData;
}
}
else
{
my $nodeValue = $targetId;
$nodeValue =~ s/.*node(\d?).*/$1/;
if ($nodeValue < $#nodeFD )
{
print {$nodeFD[$nodeValue]} $xmlData;
}
elsif ($nodeValue == $#nodeFD)
{
print {$nodeFD[0]} $xmlData;
}
else
{
die "ERROR: node value($nodeValue) is not in the range of possible nodes\n";
}
}
}
#close file descriptors
for my $k(0..$#nodeOutFiles)
{
my $filename= sprintf("%s",@{$nodeOutFiles[$k]});
close $nodeFD[$k] ||
die "ERROR: unable to close $filename\n";
}
exit 0;
################################################################################
#subroutines below
################################################################################
#subroutines below
sub display_help
{
use File::Basename;
my $scriptname = basename($0);
print STDERR "
Usage:
$scriptname --help
--help
displays usage
$scriptname --system=sysname --mrwdir=pathname
--build=hb --nodeCount=nodeCount
--system=systemname
Specify which system MRW XML to be generated
The system name will be set as uppercase
--mrwdir=pathname
Specify the complete dir pathname of the MRW.
--build=hb/fsp
Specify if HostBoot build (hb) or FSP build (fsp)
--nodeCount
Specify the max number of nodes for the system
\n";
}
|