Gunnar Mills | bff5684 | 2017-09-25 15:49:16 -0500 | [diff] [blame^] | 1 | #!/usr/bin/env perl |
| 2 | use strict; |
| 3 | use warnings; |
| 4 | |
| 5 | use mrw::Targets; # Set of APIs allowing access to parsed ServerWiz2 XML output |
| 6 | use Getopt::Long; # For parsing command line arguments |
| 7 | |
| 8 | # Globals |
| 9 | my $force = 0; |
| 10 | my $serverwizFile = ""; |
| 11 | my $debug = 0; |
| 12 | my $outputFile = ""; |
| 13 | |
| 14 | # Command line argument parsing |
| 15 | GetOptions( |
| 16 | "f" => \$force, # numeric |
| 17 | "i=s" => \$serverwizFile, # string |
| 18 | "o=s" => \$outputFile, # string |
| 19 | "d" => \$debug, |
| 20 | ) |
| 21 | or printUsage(); |
| 22 | |
| 23 | if (($serverwizFile eq "") or ($outputFile eq "")) |
| 24 | { |
| 25 | printUsage(); |
| 26 | } |
| 27 | |
| 28 | # API used to access parsed XML data |
| 29 | my $targetObj = Targets->new; |
| 30 | if($debug == 1) |
| 31 | { |
| 32 | $targetObj->{debug} = 1; |
| 33 | } |
| 34 | |
| 35 | if($force == 1) |
| 36 | { |
| 37 | $targetObj->{force} = 1; |
| 38 | } |
| 39 | |
| 40 | $targetObj->loadXML($serverwizFile); |
| 41 | print "Loaded MRW XML: $serverwizFile \n"; |
| 42 | |
| 43 | # Usage |
| 44 | sub printUsage |
| 45 | { |
| 46 | print " |
| 47 | $0 -i [XML filename] -o [Output filename] [OPTIONS] |
| 48 | Options: |
| 49 | -f = force output file creation even when errors |
| 50 | -d = debug mode |
| 51 | |
| 52 | PS: mrw::Targets can be found in https://github.com/open-power/serverwiz/ |
| 53 | mrw::Inventory can be found in https://github.com/openbmc/phosphor-mrw-tools/ |
| 54 | \n"; |
| 55 | exit(1); |
| 56 | } |