Add tool to dump out all targets and attributes
Prints out every target along with its attributes for debug.
Looks like:
--------------------------------------------------------------
Target /sys-0/node-0/motherboard-0/proc_socket-0/module-0/p9_proc_m/eq2/core9
MRW_TYPE: NA
CHIPLET_ID: 0x29
CDM_DOMAIN: CPU
PRIMARY_CAPABILITIES:
reserved: 0
supportsFsiScom: 1
supportsInbandScom: 0
supportsXscom: 1
MODEL:
HWAS_STATE_CHANGED_FLAG: 0x0
CLASS: UNIT
HWAS_STATE_CHANGED_SUBSCRIPTION_MASK: 0x00000001
PHYS_PATH:
FRU_NAME: CORE9
BUS_TYPE: NA
FRU_ID: 1
TYPE: CORE
RESOURCE_IS_CRITICAL: 0
DUMMY_RW: 5
CHIP_UNIT: 9
INSTANCE_PATH: instance:sys-0/node-0/motherboard-0/proc_socket-0/core
DECONFIG_GARDABLE: 1
IPMI_INSTANCE: 9
IPMI_SENSORS:
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I65f79ca0e85adfe93f6ff5d9dc5da6948757e1e0
diff --git a/print_targets.pl b/print_targets.pl
new file mode 100755
index 0000000..918e022
--- /dev/null
+++ b/print_targets.pl
@@ -0,0 +1,46 @@
+#! /usr/bin/perl
+
+use strict;
+use warnings;
+use mrw::Targets;
+
+my $targetObj;
+my $serverwizFile = $ARGV[0];
+if ((not defined $serverwizFile) || (! -e $serverwizFile)) {
+ die "Usage: $0 [XML filename]\n";
+}
+
+$targetObj = Targets->new;
+$targetObj->loadXML($serverwizFile);
+
+dumpMRW($targetObj);
+
+sub dumpMRW
+{
+ my ($targetObj) = @_;
+
+ for my $target (sort keys %{$targetObj->getAllTargets()}) {
+ print "-----------------------------------------------------------\n";
+ print "Target $target\n";
+ my $thash = $targetObj->getTarget($target);
+
+ for my $attr (keys %{$thash->{ATTRIBUTES}}) {
+ print "\t$attr: ";
+
+ if (ref($thash->{ATTRIBUTES}->{$attr}->{default}) eq "HASH") {
+ print "\n";
+
+ for my $f (sort keys %{$thash->{ATTRIBUTES}->
+ {$attr}->{default}->{field}}) {
+
+ my $val = $thash->{ATTRIBUTES}->
+ {$attr}->{default}->{field}->{$f}->{value};
+ print "\t\t$f: $val\n";
+ }
+ }
+ else {
+ print $thash->{ATTRIBUTES}->{$attr}->{default} . "\n";
+ }
+ }
+ }
+}