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