summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGunnar Mills <gmills@us.ibm.com>2018-01-26 15:28:26 -0600
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2018-02-13 00:53:51 +0000
commitdab1c6d1cb52657d90f1ac112c5528eea6040eed (patch)
tree4b90e4cd1c7eb0837978982c6c3e79a20730bb12
parentd641c086b5cc5f873c69aab454d1d3297e178192 (diff)
downloadpyphosphor-dab1c6d1cb52657d90f1ac112c5528eea6040eed.tar.gz
pyphosphor-dab1c6d1cb52657d90f1ac112c5528eea6040eed.zip
Point PowerSupplyRedundancySensor to new interface
The PowerSupplyRedundancy sensor is used by the Host to know whether the system has redundant power supply support. The sensor is implemented under the legacy openbmc/pyphosphor repo which does not persist it's values. This commit will move this sensor into the official phosphor settings repo (which does have persistency support) but also keep the legacy interfaces in place for backwards compatibility. The PowerSupplyRedundancySensor should look at the new PowerSupplyRedundancy interface for its value and when setting the PowerSupplyRedundancySensor, set the new value. Resolves openbmc/openbmc#2833 Change-Id: I490d385efba70f26b1a3eac87074b1fa0f8cd907 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
-rw-r--r--obmc/sensors.py43
1 files changed, 42 insertions, 1 deletions
diff --git a/obmc/sensors.py b/obmc/sensors.py
index fba7a91..b8c26ed 100644
--- a/obmc/sensors.py
+++ b/obmc/sensors.py
@@ -110,7 +110,48 @@ class OperatingSystemStatusSensor(VirtualSensor):
class PowerSupplyRedundancySensor(VirtualSensor):
def __init__(self, bus, name):
VirtualSensor.__init__(self, bus, name)
- self.setValue("Enabled")
+ self.bus = bus
+ self.bus_name = 'xyz.openbmc_project.Settings'
+ self.obj_path = '/xyz/openbmc_project/control/power_supply_redundancy'
+ self.iface = 'xyz.openbmc_project.Control.PowerSupplyRedundancy'
+ self.prop_iface = 'org.freedesktop.DBus.Properties'
+ self.property_name = 'PowerSupplyRedundancyEnabled'
+ super(PowerSupplyRedundancySensor, self).setValue(self.getValue())
+
+ # Override setValue method
+ @dbus.service.method(
+ SensorValue.IFACE_NAME, in_signature='v', out_signature='')
+ def setValue(self, value):
+ if (value == "Enabled"):
+ intf = self.getPowerSupplyInterface()
+ intf.Set(self.iface, self.property_name, True)
+ elif (value == "Disabled"):
+ intf = self.getPowerSupplyInterface()
+ intf.Set(self.iface, self.property_name, False)
+ else:
+ print "Invalid Power Supply Redundancy value"
+ return
+ super(PowerSupplyRedundancySensor, self).setValue(value)
+
+ # Override getValue method
+ @dbus.service.method(
+ SensorValue.IFACE_NAME, in_signature='', out_signature='v')
+ def getValue(self):
+ intf = self.getPowerSupplyInterface()
+ value = intf.Get(self.iface, self.property_name)
+ if (value == 1):
+ return "Enabled"
+ elif (value == 0):
+ return "Disabled"
+ else:
+ print "Unable to determine Power Supply Redundancy value"
+ return ""
+
+ def getPowerSupplyInterface(self):
+ obj = self.bus.get_object(self.bus_name, self.obj_path,
+ introspect=True)
+ return dbus.Interface(obj, self.prop_iface)
+
class PowerSupplyDeratingSensor(VirtualSensor):
def __init__(self, bus, name):
OpenPOWER on IntegriCloud