summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGunnar Mills <gmills@us.ibm.com>2017-09-26 16:19:32 -0500
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2017-10-10 14:02:35 +0000
commit457653333a01917ca4297b76110232e64c50da16 (patch)
tree2b6b04f805832f32d39c54bdb39054e57c16ac3d
parentbff568414417de7e487b7722858cb7f7634546a3 (diff)
downloadphosphor-mrw-tools-457653333a01917ca4297b76110232e64c50da16.tar.gz
phosphor-mrw-tools-457653333a01917ca4297b76110232e64c50da16.zip
Get settings values from the MRW
Replace any MRW variables in the setting YAML with their MRW value. An MRW variable must be in the MRW_<MRW variable name> format. Change-Id: Ic7e163beb4f5d13cae00ff2013b1c4080d39a256 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
-rwxr-xr-xgen_settings.pl39
1 files changed, 34 insertions, 5 deletions
diff --git a/gen_settings.pl b/gen_settings.pl
index 06794ff..d3389b5 100755
--- a/gen_settings.pl
+++ b/gen_settings.pl
@@ -10,17 +10,19 @@ my $force = 0;
my $serverwizFile = "";
my $debug = 0;
my $outputFile = "";
+my $settingsFile = "";
# Command line argument parsing
GetOptions(
"f" => \$force, # numeric
"i=s" => \$serverwizFile, # string
"o=s" => \$outputFile, # string
+"s=s" => \$settingsFile, # string
"d" => \$debug,
)
or printUsage();
-if (($serverwizFile eq "") or ($outputFile eq ""))
+if (($serverwizFile eq "") or ($outputFile eq "") or ($settingsFile eq "") )
{
printUsage();
}
@@ -40,17 +42,44 @@ if($force == 1)
$targetObj->loadXML($serverwizFile);
print "Loaded MRW XML: $serverwizFile \n";
+open(my $inFh, '<', $settingsFile) or die "Could not open file '$settingsFile' $!";
+open(my $outFh, '>', $outputFile) or die "Could not open file '$outputFile' $!";
+
+# Process all the targets in the XML
+foreach my $target (sort keys %{$targetObj->getAllTargets()})
+{
+ # A future improvement could be to specify the MRW target.
+ next if ("SYS" ne $targetObj->getType($target, "TYPE"));
+ # Read the settings YAML replacing any MRW_<variable name> with their
+ # MRW value
+ while (my $row = <$inFh>)
+ {
+ while ($row =~ /MRW_(.*?)\W/g)
+ {
+ my $setting = $1;
+ my $settingValue = $targetObj->getAttribute($target, $setting);
+ $row =~ s/MRW_${setting}/$settingValue/g;
+ }
+ print $outFh $row;
+ }
+ last;
+ close $inFh;
+ close $outFh;
+}
+
# Usage
sub printUsage
{
print "
- $0 -i [XML filename] -o [Output filename] [OPTIONS]
+ $0 -i [XML filename] -s [Settings YAML] -o [Output filename] [OPTIONS]
+
+Required:
+ -i = MRW XML filename
+ -s = The Setting YAML with MRW variables in MRW_<MRW variable name> format
+ -o = YAML output filename
Options:
-f = force output file creation even when errors
-d = debug mode
-
-PS: mrw::Targets can be found in https://github.com/open-power/serverwiz/
- mrw::Inventory can be found in https://github.com/openbmc/phosphor-mrw-tools/
\n";
exit(1);
}
OpenPOWER on IntegriCloud