diff options
author | Brad Bishop <bradleyb@us.ibm.com> | 2015-09-22 00:16:16 +0300 |
---|---|---|
committer | Brad Bishop <bradleyb@us.ibm.com> | 2015-09-22 00:17:17 +0300 |
commit | 43b381cf211aa02d039a3c6f775d3ae3f1e3d7f5 (patch) | |
tree | 807a411209569b156320f7f33448a319e597bc63 | |
parent | 4539dad430a4a4d1dd0cbb7efe1d63c2e37e91f2 (diff) | |
download | openbmc-43b381cf211aa02d039a3c6f775d3ae3f1e3d7f5.tar.xz |
Refactor obmc-phosphor-qemu
Renamed to obmc-phosphor-example-pydbus.
Prep for forthcoming sdbus example.
Added signal example.
7 files changed, 41 insertions, 37 deletions
diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-qemu/files/obmc-phosphor-qemu.py b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/obmc-phosphor-example-pydbus.py index 3ef8e852e..b0523b379 100644 --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-qemu/files/obmc-phosphor-qemu.py +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/obmc-phosphor-example-pydbus.py @@ -22,50 +22,56 @@ import dbus.service import dbus.mainloop.glib import gobject -SERVICE_PREFIX = 'org.openbmc.examples.services' -IFACE_PREFIX = 'org.openbmc.examples.interfaces' +SERVICE_PREFIX = 'org.openbmc.examples' +IFACE_PREFIX = 'org.openbmc.examples' BASE_OBJ_PATH = '/org/openbmc/examples/' class SampleObjectOne(dbus.service.Object): def __init__(self, bus, name): super(SampleObjectOne, self).__init__(bus, name) - @dbus.service.method(IFACE_PREFIX + '.Interface0', 's', 's') - def echo(self, val): - return str(type(self).__name__) + ": " + val + @dbus.service.method(IFACE_PREFIX + '.Echo', 's', 's') + def Echo(self, val): + self.MethodInvoked("Echo method was invoked", self._object_path) + return self._object_path + " says " + val + + @dbus.service.signal(IFACE_PREFIX + '.Echo', 'ss') + def MethodInvoked(self, message, path): + pass class SampleObjectTwo(SampleObjectOne): def __init__(self, bus, name): super(SampleObjectTwo, self).__init__(bus, name) self.map = {} - @dbus.service.method(IFACE_PREFIX + '.Interface1', 'ss', '') - def set_a_value_in_the_dict(self, key, value): + @dbus.service.method(IFACE_PREFIX + '.Dict', 'ss', '') + def SetAValueInTheDict(self, key, value): self.map[key] = value - @dbus.service.method(IFACE_PREFIX + '.Interface1', 's', 's') - def get_a_value_from_the_dict(self, key): + @dbus.service.method(IFACE_PREFIX + '.Dict', 's', 's') + def GetAValueFromTheDict(self, key): return self.map.get(key, "set a value first") - @dbus.service.method(IFACE_PREFIX + '.Interface1', '', 's') - def get_all_values_from_the_dict(self): + @dbus.service.method(IFACE_PREFIX + '.Dict', '', 's') + def GetAllValuesFromTheDict(self): return " ".join( [ x+ ':' + self.map[x] for x in self.map.keys() ] ) + if __name__ == '__main__': dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) bus = dbus.SystemBus() services = [] - services.append(dbus.service.BusName(SERVICE_PREFIX + '.Service0', bus)) - services.append(dbus.service.BusName(SERVICE_PREFIX + '.Service1', bus)) + services.append(dbus.service.BusName(SERVICE_PREFIX + '.PythonService0', bus)) + services.append(dbus.service.BusName(SERVICE_PREFIX + '.PythonService1', bus)) objs = [] - objs.append(SampleObjectOne(bus, BASE_OBJ_PATH + 'path0/Obj')) - objs.append(SampleObjectTwo(bus, BASE_OBJ_PATH + 'path1/Obj')) + objs.append(SampleObjectOne(bus, BASE_OBJ_PATH + 'path0/PythonObj')) + objs.append(SampleObjectTwo(bus, BASE_OBJ_PATH + 'path1/PythonObj')) mainloop = gobject.MainLoop() - print "obmc-phosphor-qemu starting..." + print "obmc-phosphor-example-pydbus starting..." mainloop.run() diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-qemu/files/obmc-phosphor-qemu.service b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/obmc-phosphor-example-pydbus.service index 0cf4e15f1..d39395f40 100644 --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-qemu/files/obmc-phosphor-qemu.service +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/obmc-phosphor-example-pydbus.service @@ -2,7 +2,7 @@ Description=Phosphor OpenBMC QEMU application example [Service] -ExecStart=/usr/sbin/obmc-phosphor-qemu +ExecStart=/usr/sbin/obmc-phosphor-example-pydbus [Install] WantedBy=multi-user.target diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-qemu/files/org.openbmc.examples.services.Service0.conf b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/org.openbmc.examples.PythonService0.conf index 1c6c5057e..fad0b81fb 100644 --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-qemu/files/org.openbmc.examples.services.Service0.conf +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/org.openbmc.examples.PythonService0.conf @@ -2,7 +2,7 @@ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> <busconfig> <policy user="root"> - <allow own="org.openbmc.examples.services.Service0"/> - <allow send_destination="org.openbmc.examples.services.Service0"/> + <allow own="org.openbmc.examples.PythonService0"/> + <allow send_destination="org.openbmc.examples.PythonService0"/> </policy> </busconfig> diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-qemu/files/org.openbmc.examples.services.Service1.conf b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/org.openbmc.examples.PythonService1.conf index cd488d588..0f7114e48 100644 --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-qemu/files/org.openbmc.examples.services.Service1.conf +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/org.openbmc.examples.PythonService1.conf @@ -2,7 +2,7 @@ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> <busconfig> <policy user="root"> - <allow own="org.openbmc.examples.services.Service1"/> - <allow send_destination="org.openbmc.examples.services.Service1"/> + <allow own="org.openbmc.examples.PythonService1"/> + <allow send_destination="org.openbmc.examples.PythonService1"/> </policy> </busconfig> diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/obmc-phosphor-example-pydbus.bb b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/obmc-phosphor-example-pydbus.bb new file mode 100644 index 000000000..7fee0b18e --- /dev/null +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/obmc-phosphor-example-pydbus.bb @@ -0,0 +1,10 @@ +SUMMARY = "Phosphor OpenBMC BSP Example Application" +DESCRIPTION = "Phosphor OpenBMC QEMU BSP example implementation." +PR = "r1" + +DBUS_SERVICES = " \ + org.openbmc.examples.PythonService0 \ + org.openbmc.examples.PythonService1 \ + " + +inherit obmc-phosphor-pydbus-service diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-qemu/obmc-phosphor-qemu.bb b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-qemu/obmc-phosphor-qemu.bb deleted file mode 100644 index 0ea535525..000000000 --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-qemu/obmc-phosphor-qemu.bb +++ /dev/null @@ -1,12 +0,0 @@ -SUMMARY = "Phosphor OpenBMC BSP Example Application" -DESCRIPTION = "Phosphor OpenBMC QEMU BSP example implementation." -PR = "r1" - -inherit obmc-phosphor-py-daemon - -DBUS_SERVICES = " \ - org.openbmc.examples.services.Service0 \ - org.openbmc.examples.services.Service1 \ - " - -inherit obmc-phosphor-dbus-service diff --git a/meta-phosphor/conf/machine/include/sample.inc b/meta-phosphor/conf/machine/include/sample.inc index 7db288350..3b67e8d3d 100644 --- a/meta-phosphor/conf/machine/include/sample.inc +++ b/meta-phosphor/conf/machine/include/sample.inc @@ -6,14 +6,14 @@ OBMC_MACHINE_FEATURES += "\ " VIRTUAL-RUNTIME_obmc-phosphor-fan-ctl = " \ - obmc-phosphor-qemu \ + obmc-phosphor-example-pydbus \ " VIRTUAL-RUNTIME_obmc-phosphor-sensor-ctl = " \ - obmc-phosphor-qemu \ + obmc-phosphor-example-pydbus \ " VIRTUAL-RUNTIME_obmc-phosphor-chassis-ctl = " \ - obmc-phosphor-qemu \ + obmc-phosphor-example-pydbus \ " VIRTUAL-RUNTIME_obmc-phosphor-flash-ctl = " \ - obmc-phosphor-qemu \ + obmc-phosphor-example-pydbus \ " |