chassis_control: Log an event when emergency shutdown host

According to BMC Firmware Specification, on occasion the BMC will be required
to shut down the host due to high ambient or fan fails. A SEL must be
present in this case.

Fixes openbmc/skeleton#64

Change-Id: I3d779fc597961821a7a7f1b0f147314072ae8802
Signed-off-by: Yi Li <adamliyi@msn.com>
diff --git a/pychassisctl/chassis_control.py b/pychassisctl/chassis_control.py
index fc18703..b3e16ff 100755
--- a/pychassisctl/chassis_control.py
+++ b/pychassisctl/chassis_control.py
@@ -229,8 +229,23 @@
         self.Set(DBUS_NAME, "reboot", 1)
         self.powerOff()
 
-    def emergency_shutdown_signal_handler(self):
+    def emergency_shutdown_signal_handler(self, message):
         print "Emergency Shutdown!"
+        # Log an event.
+        try:
+            # Exception happens or not, we need to power off.
+            obj = bus.get_object("org.openbmc.records.events",
+                                 "/org/openbmc/records/events",
+                                 introspect=False)
+            intf = dbus.Interface(obj, "org.openbmc.recordlog")
+            desc = message
+            sev = "critical error"
+            details = "Get emergency shutdown signal. Shutdown the host."
+            debug = dbus.ByteArray("")
+            intf.acceptBMCMessage(desc, sev, details, debug)
+        except Exception as e:
+            print "Emergency shutdown signal handler: log event error."
+            print e
         self.powerOff()