summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarri Devender Rao <devenrao@in.ibm.com>2018-03-20 03:15:10 -0500
committerMatt Spinler <spinler@us.ibm.com>2018-03-23 15:33:42 +0000
commit17f0679b8acee7565adbc7a461d8d280826fed18 (patch)
treedbb9934568c223cf3fb370da32c0a6d357503759
parent64e084d809cf4409147df6b7391ef94b2f37715c (diff)
downloadphosphor-mrw-tools-17f0679b8acee7565adbc7a461d8d280826fed18.zip
phosphor-mrw-tools-17f0679b8acee7565adbc7a461d8d280826fed18.tar.gz
Seperate write interface method file for reuse
Seperated out write interfaces to a new method so that it can be used for writing temperature sensor data. Change-Id: I6b44d1dc2623230c3ec726e1ad18790a93ad7497 Signed-off-by: Marri Devender Rao <devenrao@in.ibm.com>
-rwxr-xr-xgen_ipmi_sensor.pl50
1 files changed, 27 insertions, 23 deletions
diff --git a/gen_ipmi_sensor.pl b/gen_ipmi_sensor.pl
index 84b00c8..74c95da 100755
--- a/gen_ipmi_sensor.pl
+++ b/gen_ipmi_sensor.pl
@@ -1,7 +1,6 @@
#! /usr/bin/perl
use strict;
use warnings;
-
use mrw::Targets;
use mrw::Inventory;
use mrw::Util;
@@ -130,10 +129,34 @@ foreach my $target (sort keys %{$targetObj->getAllTargets()})
}
close $fh;
+#Write the interfaces data into the output file
+sub writeInterfaces
+{
+ my ($interfaces, $fh) = @_;
+ print $fh " interfaces:"."\n";
+ #Walk over all the interfces as it needs to be written
+ while (my ($interface,$properties) = each %{$interfaces}) {
+ print $fh " ".$interface.":\n";
+ #walk over all the properties as it needs to be written
+ while (my ($dbusProperty,$dbusPropertyValue) = each %{$properties}) {
+ #will write property named "Property" first then
+ #other properties.
+ print $fh " ".$dbusProperty.":\n";
+ while (my ($condition,$offsets) = each %{$dbusPropertyValue}) {
+ print $fh " $condition:\n";
+ while (my ($offset,$values) = each %{$offsets}) {
+ print $fh " $offset:\n";
+ while (my ($key,$value) = each %{$values}) {
+ print $fh " $key: ". $value."\n";
+ }
+ }
+ }
+ }
+ }
+}
#Get the metadata for the incoming sensortype from the loaded config file.
#Write the sensor data into the output file
-
sub writeToFile
{
my ($sensorName,$sensorType,$sensorReadingType,$path,$serviceInterface,
@@ -149,31 +172,12 @@ sub writeToFile
print $fh " serviceInterface: ".$serviceInterface."\n";
print $fh " readingType: ".$readingType."\n";
print $fh " sensorNamePattern: ".$sensorNamePattern."\n";
- print $fh " interfaces:"."\n";
my $interfaces = $sensorTypeConfig->{$sensorName}->{"interfaces"};
- #Walk over all the interfces as it needs to be written
- while (my ($interface,$properties) = each %{$interfaces}) {
- print $fh " ".$interface.":\n";
- #walk over all the properties as it needs to be written
- while (my ($dbusProperty,$dbusPropertyValue) = each %{$properties}) {
- #will write property named "Property" first then
- #other properties.
- print $fh " ".$dbusProperty.":\n";
- while (my ($condition,$offsets) = each %{$dbusPropertyValue}) {
- print $fh " $condition:\n";
- while (my ($offset,$values) = each %{$offsets}) {
- print $fh " $offset:\n";
- while (my ($key,$value) = each %{$values}) {
- print $fh " $key: ". $value."\n";
- }
- }
- }
- }
- }
+ writeInterfaces($interfaces, $fh);
}
-# Convert MRW OCC inventory path to application d-bus path
+#Convert MRW OCC inventory path to application d-bus path
sub checkOccPathFixup
{
my ($path) = @_;
OpenPOWER on IntegriCloud