summaryrefslogtreecommitdiffstats
path: root/Util.pm
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2017-01-09 15:42:05 -0600
committerMatt Spinler <spinler@us.ibm.com>2017-01-17 10:27:27 -0600
commit8df7be8f60050469b8989e9656b061bc6c3c37f1 (patch)
tree590a724873017f9f09bb32265cd1897566954788 /Util.pm
parent3706646aa8cc16897b3af96969eb133f9ba0d2f8 (diff)
downloadphosphor-mrw-tools-8df7be8f60050469b8989e9656b061bc6c3c37f1.tar.gz
phosphor-mrw-tools-8df7be8f60050469b8989e9656b061bc6c3c37f1.zip
Create hwmon.pl
This script will create configuration files for hwmon sensors for the phosphor-hwmon daemon. This is the first of several commits for this script. Change-Id: Ie8f59b0c94fe9c61c454ed7dde816d7c819728fc Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Diffstat (limited to 'Util.pm')
-rw-r--r--Util.pm72
1 files changed, 72 insertions, 0 deletions
diff --git a/Util.pm b/Util.pm
new file mode 100644
index 0000000..d85726a
--- /dev/null
+++ b/Util.pm
@@ -0,0 +1,72 @@
+package Util;
+
+#Holds common utility functions for MRW processing.
+
+use strict;
+use warnings;
+
+use mrw::Targets;
+
+#Returns the BMC target for a system.
+# param[in] $targetObj = The Targets object
+sub getBMCTarget
+{
+ my ($targetObj) = @_;
+
+ for my $target (keys %{$targetObj->getAllTargets()}) {
+ if ($targetObj->getType($target) eq "BMC") {
+ return $target;
+ }
+ }
+
+ die "Could not find BMC target in the MRW XML\n";
+}
+
+
+#Returns an array of child units based on their Target Type.
+# param[in] $targetObj = The Targets object
+# param[in] $unitTargetType = The target type of the units to find
+# param[in] $chip = The chip target to find the units on
+sub getChildUnitsWithTargetType
+{
+ my ($targetObj, $unitTargetType, $chip) = @_;
+ my @units;
+
+ my @children = $targetObj->getAllTargetChildren($chip);
+
+ for my $child (@children) {
+ if ($targetObj->getTargetType($child) eq $unitTargetType) {
+ push @units, $child;
+ }
+ }
+
+ return @units;
+}
+
+1;
+
+=head1 NAME
+
+Util
+
+=head1 DESCRIPTION
+
+Contains utility functions for the MRW parsers.
+
+=head1 METHODS
+
+=over 4
+
+=item getBMCTarget(C<TargetsObj>)
+
+Returns the target string for the BMC chip. If it can't find one,
+it will die. Currently supports single BMC systems.
+
+=item getChildUnitsWithTargetType(C<TargetsObj>, C<TargetType>, C<ChipTarget>)
+
+Returns an array of targets that have target-type C<TargetType>
+and are children (any level) of target C<ChipTarget>.
+
+=back
+
+=cut
OpenPOWER on IntegriCloud