Refactor obmc-phosphor-qemu
Renamed to obmc-phosphor-example-pydbus.
Prep for forthcoming sdbus example.
Added signal example.
diff --git a/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/obmc-phosphor-example-pydbus.py b/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/obmc-phosphor-example-pydbus.py
new file mode 100644
index 0000000..b0523b3
--- /dev/null
+++ b/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/obmc-phosphor-example-pydbus.py
@@ -0,0 +1,77 @@
+#!/usr/bin/env python
+
+# Contributors Listed Below - COPYRIGHT 2015
+# [+] International Business Machines Corp.
+#
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+
+import sys
+import dbus
+import dbus.service
+import dbus.mainloop.glib
+import gobject
+
+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 + '.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 + '.Dict', 'ss', '')
+ def SetAValueInTheDict(self, key, value):
+ self.map[key] = value
+
+ @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 + '.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 + '.PythonService0', bus))
+ services.append(dbus.service.BusName(SERVICE_PREFIX + '.PythonService1', bus))
+
+ objs = []
+ objs.append(SampleObjectOne(bus, BASE_OBJ_PATH + 'path0/PythonObj'))
+ objs.append(SampleObjectTwo(bus, BASE_OBJ_PATH + 'path1/PythonObj'))
+
+ mainloop = gobject.MainLoop()
+
+ print "obmc-phosphor-example-pydbus starting..."
+ mainloop.run()
+
diff --git a/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/obmc-phosphor-example-pydbus.service b/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/obmc-phosphor-example-pydbus.service
new file mode 100644
index 0000000..d39395f
--- /dev/null
+++ b/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/obmc-phosphor-example-pydbus.service
@@ -0,0 +1,8 @@
+[Unit]
+Description=Phosphor OpenBMC QEMU application example
+
+[Service]
+ExecStart=/usr/sbin/obmc-phosphor-example-pydbus
+
+[Install]
+WantedBy=multi-user.target
diff --git a/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/org.openbmc.examples.PythonService0.conf b/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/org.openbmc.examples.PythonService0.conf
new file mode 100644
index 0000000..fad0b81
--- /dev/null
+++ b/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/org.openbmc.examples.PythonService0.conf
@@ -0,0 +1,8 @@
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <policy user="root">
+ <allow own="org.openbmc.examples.PythonService0"/>
+ <allow send_destination="org.openbmc.examples.PythonService0"/>
+ </policy>
+</busconfig>
diff --git a/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/org.openbmc.examples.PythonService1.conf b/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/org.openbmc.examples.PythonService1.conf
new file mode 100644
index 0000000..0f7114e
--- /dev/null
+++ b/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/org.openbmc.examples.PythonService1.conf
@@ -0,0 +1,8 @@
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <policy user="root">
+ <allow own="org.openbmc.examples.PythonService1"/>
+ <allow send_destination="org.openbmc.examples.PythonService1"/>
+ </policy>
+</busconfig>