blob: 34b19ee95a4fb6c9e3d5d0967b2108519bcbc581 [file] [log] [blame]
Ratan Guptafa70dc92017-01-17 00:09:04 +05301#! /usr/bin/perl
2use strict;
3use warnings;
4
5use mrw::Targets;
6use mrw::Inventory;
7use Getopt::Long; # For parsing command line arguments
8use YAML::XS 'LoadFile'; # For loading and reading of YAML file
9
10# Globals
11my $serverwizFile = "";
12my $debug = 0;
13
14# Command line argument parsing
15GetOptions(
16"i=s" => \$serverwizFile, # string
17"d" => \$debug,
18)
19or printUsage();
20
21if (($serverwizFile eq ""))
22{
23 printUsage();
24}
25
26my $targetObj = Targets->new;
27$targetObj->loadXML($serverwizFile);
28
29#open the mrw xml Fetch the FRU id,type,object path from the mrw.
30
31my @inventory = Inventory::getInventory($targetObj);
32for my $item (@inventory) {
33 my $isFru = 0, my $fruID = 0, my $fruType = "";
34 my $isChildFru = 0;
35
36 #Fetch the fruid.
37 if (!$targetObj->isBadAttribute($item->{TARGET}, "FRU_ID")) {
38 $fruID = $targetObj->getAttribute($item->{TARGET}, "FRU_ID");
39 $isFru = 1;
40 }
41
42 #Fech the fru type.
43 if (!$targetObj->isBadAttribute($item->{TARGET}, "TYPE")) {
44 $fruType = $targetObj->getAttribute($item->{TARGET}, "TYPE");
45 }
46
47 #skip those entries whose type is NA and is not fru.
48 next if ( $fruType eq 'NA' or not($isFru) or $fruType eq 'BMC');
49
50 printDebug ("FRUID => $fruID, FRUType => $fruType, ObjectPath => $item->{OBMC_NAME}");
51
52}
53#------------------------------------END OF MAIN-----------------------
54
55# Usage
56sub printUsage
57{
58 print "
59 $0 -i [MRW filename] [OPTIONS]
60Options:
61 -d = debug mode
62 \n";
63 exit(1);
64}
65
66# Helper function to put debug statements.
67sub printDebug
68{
69 my $str = shift;
70 print "DEBUG: ", $str, "\n" if $debug;
71}