Refactor obmc-phosphor-qemu
Renamed to obmc-phosphor-example-pydbus.
Prep for forthcoming sdbus example.
Added signal example.
diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/obmc-phosphor-example-pydbus.py b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/obmc-phosphor-example-pydbus.py
new file mode 100644
index 0000000..b0523b3
--- /dev/null
+++ b/meta-phosphor/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/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
similarity index 68%
rename from meta-phosphor/common/recipes-phosphor/obmc-phosphor-qemu/files/obmc-phosphor-qemu.service
rename to meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/obmc-phosphor-example-pydbus.service
index 0cf4e15..d39395f 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.Service1.conf b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/org.openbmc.examples.PythonService0.conf
similarity index 61%
copy from meta-phosphor/common/recipes-phosphor/obmc-phosphor-qemu/files/org.openbmc.examples.services.Service1.conf
copy to meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/org.openbmc.examples.PythonService0.conf
index cd488d5..fad0b81 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.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.Service1"/>
- <allow send_destination="org.openbmc.examples.services.Service1"/>
+ <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
similarity index 61%
rename from meta-phosphor/common/recipes-phosphor/obmc-phosphor-qemu/files/org.openbmc.examples.services.Service1.conf
rename to meta-phosphor/common/recipes-phosphor/obmc-phosphor-example-pydbus/files/org.openbmc.examples.PythonService1.conf
index cd488d5..0f7114e 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 0000000..7fee0b1
--- /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/files/obmc-phosphor-qemu.py b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-qemu/files/obmc-phosphor-qemu.py
deleted file mode 100644
index 3ef8e85..0000000
--- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-qemu/files/obmc-phosphor-qemu.py
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/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.services'
-IFACE_PREFIX = 'org.openbmc.examples.interfaces'
-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
-
-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):
- self.map[key] = value
-
- @dbus.service.method(IFACE_PREFIX + '.Interface1', 's', 's')
- def get_a_value_from_the_dict(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):
- 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))
-
- objs = []
- objs.append(SampleObjectOne(bus, BASE_OBJ_PATH + 'path0/Obj'))
- objs.append(SampleObjectTwo(bus, BASE_OBJ_PATH + 'path1/Obj'))
-
- mainloop = gobject.MainLoop()
-
- print "obmc-phosphor-qemu starting..."
- mainloop.run()
-
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-qemu/files/org.openbmc.examples.services.Service0.conf
deleted file mode 100644
index 1c6c505..0000000
--- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-qemu/files/org.openbmc.examples.services.Service0.conf
+++ /dev/null
@@ -1,8 +0,0 @@
-<!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.services.Service0"/>
- <allow send_destination="org.openbmc.examples.services.Service0"/>
- </policy>
-</busconfig>
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 0ea5355..0000000
--- 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 7db2883..3b67e8d 100644
--- a/meta-phosphor/conf/machine/include/sample.inc
+++ b/meta-phosphor/conf/machine/include/sample.inc
@@ -6,14 +6,14 @@
"
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 \
"