add power policy handling
diff --git a/bin/chassis_control.py b/bin/chassis_control.py
index fa3b9b6..2ed954e 100755
--- a/bin/chassis_control.py
+++ b/bin/chassis_control.py
@@ -46,13 +46,16 @@
 				'object_name' : '/org/openbmc/HostServices',
 				'interface_name' : 'org.openbmc.HostServices'
 			},
+			'settings' : {
+				'bus_name' : 'org.openbmc.settings.Host',
+				'object_name' : '/org/openbmc/settings/host0',
+				'interface_name' : 'org.freedesktop.DBus.Properties'
+			},
 		}
 
 		#uuid
 		self.Set(DBUS_NAME,"uuid",str(uuid.uuid1()))
 		self.Set(DBUS_NAME,"reboot",0)
-		self.Set(DBUS_NAME,"power_policy",0)	
-		self.Set(DBUS_NAME,"last_system_state","")
 
 		bus.add_signal_receiver(self.power_button_signal_handler, 
 					dbus_interface = "org.openbmc.Button", signal_name = "Released", 
@@ -156,25 +159,15 @@
 		intf = self.getInterface('power_control')
 		return intf.getPowerState()
 
-	@dbus.service.method(DBUS_NAME,
-		in_signature='', out_signature='')
-	def setDebugMode(self):
-		return None
-
-	@dbus.service.method(DBUS_NAME,
-		in_signature='i', out_signature='')
-	def setPowerPolicy(self,policy):
-		self.Set(DBUS_NAME,"power_policy",policy)	
-		return None
-
-
 	## Signal handler
 
 	def SystemStateHandler(self,state_name):
-		self.Set(DBUS_NAME,"last_system_state",state_name)	
+		if (state_name == "HOST_POWERED_OFF" or state_name == "HOST_POWERED_ON"):
+			intf = self.getInterface('settings')
+			intf.Set("org.openbmc.settings.Host","system_state",state_name)
+
 		if (state_name == "HOST_POWERED_OFF" and self.Get(DBUS_NAME,"reboot")==1):
 			self.powerOn()
-				
 
 	def power_button_signal_handler(self):
 		# toggle power
diff --git a/bin/discover_system_state.py b/bin/discover_system_state.py
index 2657ca1..5bd8fdc 100755
--- a/bin/discover_system_state.py
+++ b/bin/discover_system_state.py
@@ -33,6 +33,11 @@
 		'object_name' : '/org/openbmc/control/chassis0',
 		'interface_name' : 'org.openbmc.control.Chassis'
 	},
+	'settings' : {
+		'bus_name' : 'org.openbmc.settings.Host',
+		'object_name' : '/org/openbmc/settings/host0',
+		'interface_name' : 'org.freedesktop.DBus.Properties'
+	},
 }
 
 def getInterface(bus,objs,key):
@@ -55,12 +60,17 @@
 	intf.setValue("Enabled")
 	intf = getInterface(bus,dbus_objects,'occstatus1')
 	intf.setValue("Enabled")
-#else:
-#	chassis_intf = getInterface(bus,dbus_objects,'chassis')
-#	if (power_policy == "ALWAYS_POWER_ON" or
-#	  (power_policy == "RESTORE_LAST_STATE" and 
-#	  saved_system_state =="HOST_BOOTED")):
-#		chassis_intf.powerOn()
+else:
+	## Power is off, so check power policy
+	settings_intf = getInterface(bus,dbus_objects,'settings')
+	system_state = settings_intf.Get("org.openbmc.settings.Host","system_state")
+	power_policy = settings_intf.Get("org.openbmc.settings.Host","power_policy")
 
+	print "Last System State: "+system_state+";  Power Policy: "+power_policy
+	chassis_intf = getInterface(bus,dbus_objects,'chassis')
+	if (power_policy == "ALWAYS_POWER_ON" or
+	   (power_policy == "RESTORE_LAST_STATE" and 
+	    system_state =="HOST_POWERED_ON")):
+		chassis_intf.powerOn()