summaryrefslogtreecommitdiffstats
path: root/print_targets.pl
blob: 918e0229926004a4a4aba662cb5334ca35ea8a33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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";
            }
        }
    }
}
OpenPOWER on IntegriCloud