| #!/usr/bin/env perl |
| use strict; |
| use warnings; |
| |
| use mrw::Targets; # Set of APIs allowing access to parsed ServerWiz2 XML output |
| use Getopt::Long; # For parsing command line arguments |
| |
| # Globals |
| my $force = 0; |
| my $serverwizFile = ""; |
| my $debug = 0; |
| my $outputFile = ""; |
| |
| # Command line argument parsing |
| GetOptions( |
| "f" => \$force, # numeric |
| "i=s" => \$serverwizFile, # string |
| "o=s" => \$outputFile, # string |
| "d" => \$debug, |
| ) |
| or printUsage(); |
| |
| if (($serverwizFile eq "") or ($outputFile eq "")) |
| { |
| printUsage(); |
| } |
| |
| # API used to access parsed XML data |
| my $targetObj = Targets->new; |
| if($debug == 1) |
| { |
| $targetObj->{debug} = 1; |
| } |
| |
| if($force == 1) |
| { |
| $targetObj->{force} = 1; |
| } |
| |
| $targetObj->loadXML($serverwizFile); |
| print "Loaded MRW XML: $serverwizFile \n"; |
| |
| # Usage |
| sub printUsage |
| { |
| print " |
| $0 -i [XML filename] -o [Output filename] [OPTIONS] |
| 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); |
| } |