lots of changes
diff --git a/bin/Barreleye.py b/bin/Barreleye.py
index d7c596b..2d5c800 100644
--- a/bin/Barreleye.py
+++ b/bin/Barreleye.py
@@ -5,7 +5,7 @@
 import Openbmc
 
 HOME_PATH = './'
-BIN_PATH = HOME_PATH
+BIN_PATH = HOME_PATH+'bin/'
 CACHE_PATH = HOME_PATH+'cache/'
 FRU_PATH = CACHE_PATH+'frus/'
 
@@ -45,32 +45,17 @@
 		]
 	}
 
-SYSTEM_CONFIG['org.openbmc.managers.Frus'] = {
+SYSTEM_CONFIG['org.openbmc.managers.Inventory'] = {
 		'system_state' : 'STANDBY',
 		'start_process' : True,
 		'monitor_process' : True,
-		'process_name' : 'fru_manager.py',
+		'process_name' : 'inventory_manager.py',
 		'heartbeat' : 'no',
 		'rest_name' : 'frus',
 		'instances' : [	
 			{
 				'name' : 'Barreleye',
-				'user_label': 'Fru Manager',
-			}
-		]
-	}
-
-SYSTEM_CONFIG['org.openbmc.managers.Ipmi'] = {
-		'system_state' : 'STANDBY',
-		'start_process' : True,
-		'monitor_process' : True,
-		'process_name' : 'ipmi_manager.py',
-		'heartbeat' : 'no',
-		'rest_name' : 'frus',
-		'instances' : [	
-			{
-				'name' : 'Barreleye',
-				'user_label': 'Ipmi Manager',
+				'user_label': 'Inventory Manager',
 			}
 		]
 	}
@@ -348,7 +333,6 @@
 		'manufacturer' : 'DELTA',
 		'fru'	       : True,
 		'location' : 'F0',
-		'sensor_link' : 'fans/Fan_0',
 	},
 	'/system/fan1' :
 	{
@@ -356,7 +340,6 @@
 		'manufacturer' : 'DELTA',
 		'fru'	       : True,
 		'location' : 'F1',
-		'sensor_link' : 'fans/Fan_1',
 	},
 	'/system/motherboard/bmc' :
 	{
@@ -376,27 +359,27 @@
 	{
 		'ftype'        : Openbmc.FRU_TYPES['CORE'],
 		'fru'	       : False,
-		'sensor_link' : 1,	
+		'sensor_id'    : 1,	
 	},
 	'/system/motherboard/cpu0/core1' :
 	{
 		'ftype'        : Openbmc.FRU_TYPES['CORE'],
 		'fru'	       : False,
-		'sensor_link' : 2,	
+		'sensor_id'    : 2,	
 	},
 	'/system/motherboard/dimm0' :
 	{
 		'ftype'        : Openbmc.FRU_TYPES['DIMM'],
 		'fru'	       : True,
 		'fru_id'       : 12,
-		'sensor_link'  : 20,	
+		'sensor_id'    : 20,	
 	},
 	'/system/motherboard/dimm1' :
 	{
 		'ftype'        : Openbmc.FRU_TYPES['DIMM'],
 		'fru'	       : True,
 		'fru_id'       : 13,
-		'sensor_link'  : 21,	
+		'sensor_id'    : 21,	
 	},
 }
 
diff --git a/bin/fru_manager.py b/bin/fru_manager.py
deleted file mode 100644
index 220b7d3..0000000
--- a/bin/fru_manager.py
+++ /dev/null
@@ -1,148 +0,0 @@
-#!/usr/bin/env python
-
-import os
-import sys
-import gobject
-import dbus
-import dbus.service
-import dbus.mainloop.glib
-import cPickle
-import json
-
-if (len(sys.argv) < 2):
-	print "Usage:  fru_manager.py [system name]"
-	exit(1)
-System = __import__(sys.argv[1])
-import Openbmc
-
-DBUS_NAME = 'org.openbmc.managers.Frus'
-OBJ_NAME = '/org/openbmc/managers/Frus'
-FRUS = System.FRU_INSTANCES
-
-class Fru:
-	def __init__(self,fru_id,data):
-		if (data.has_key('ftype') == False):
-			raise Exception("Fru must have ftype")
-
-		self.fru_id = fru_id
-		self.data = { 'fru_id' : fru_id }
-		self.ftype = data['ftype']
-		self.update(data)
-	
-	def getField(self,field):
-		return self.data[field]
-
-	def getId(self):
-		return self.fru_id
-
-	def update(self,data):
-		for k in data.keys():
-			self.data[k] = data[k]
-
-	def isCached(self):
-		is_cached = False
-		if (self.data.has_key('cache')):
-			if (self.data['cache']):
-				is_cached = True
-		return is_cached
-	
-	def saveToCache(self):
-		if (self.isCached() == False):
-			return
-		global FRU_PATH
-		print "Caching: "+str(self.fru_id)
-		filename = FRU_PATH+"fru_"+str(self.fru_id)
-		output = open(filename, 'wb')
-		## just pickle dict not whole object
-		cPickle.dump(self.data,output)
-		output.close()		
-
-	def loadFromCache(self):
-		if (self.isCached() == False):
-			return;
-		## overlay with pickled data
-		global FRU_PATH
-		filename = FRU_PATH+"fru_"+str(self.fru_id)
-
-		if (os.path.isfile(filename)):
-			print "Loading from cache: "+filename
-			p = open(filename, 'rb')
-			data2 = cPickle.load(p)
-			for k in data2.keys():
-				self.data[k] = data2[k]
-	def toJson(self):
-		return json.dumps(self.data)
-
-	def __str__(self):	
-		r = "Fru: "+str(self.fru_id)+"\n"
-		for f in self.data.keys():
-			r = r+f+" = "+str(self.data[f])+"\n"
-		return r
-
-		
-
-class FruManager(dbus.service.Object):
-	def __init__(self,bus,name):
-		dbus.service.Object.__init__(self,bus,name)
-		
-		bus.add_signal_receiver(self.UpdateFruHandler,
-					signal_name = 'UpdateFru')
-
-		self.fru_db = {}
-		self.fru_id_lookup = {}
-		for fru in FRUS.keys():
-			#self.updateFru(fid,System.FRUS[fid])
-			if (FRUS[fru].has_key('fru_id')):
-				print fru
-				print FRUS[fru]['fru_id']
-			
-	def UpdateFruHandler(self,fru_id,data):
-		self.updateFru(fru_id,data)		
-
-	@dbus.service.method(DBUS_NAME,
-		in_signature='isv', out_signature='')
-	def updateFruField(self,fru_id,field,value):
-		data = { field : value }
-		self.updateFru(fru_id,data)
-
-	@dbus.service.method(DBUS_NAME,
-		in_signature='ia{sv}', out_signature='')
-	def updateFru(self,fru_id,data):
-		## translate dbus data into basic data types
-		for k in data.keys():
-			d = Openbmc.DbusProperty(k,data[k])
-			data[k] = d.getBaseValue()
-
-		if (self.fru_db.has_key(fru_id)):
-			## update properties then save to cache
-			print "Updating FRU: "+str(fru_id)
-			self.fru_db[fru_id].update(data)
-			self.fru_db[fru_id].saveToCache()
-		else:
-			## fru doesn't exist, so add
-			## then overlay with data from cache
-			print "Adding FRU: "+str(fru_id)
-			fru = Fru(fru_id,data)
-			self.fru_db[fru_id] = fru
-			fru.loadFromCache()
-
-
-	@dbus.service.method(DBUS_NAME,
-		in_signature='', out_signature='s')
-	def getFrus(self):
-		r = ""
-		for f in self.fru_db.keys():
-			r=r+"["+self.fru_db[f].toJson()+"],"
-		return r
-
-
-if __name__ == '__main__':
-    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
-    bus = dbus.SessionBus()
-    name = dbus.service.BusName(DBUS_NAME,bus)
-    obj = FruManager(bus,OBJ_NAME)
-    mainloop = gobject.MainLoop()
-
-    print "Running Fru Manager"
-    mainloop.run()
-
diff --git a/bin/inventory_manager.py b/bin/inventory_manager.py
new file mode 100644
index 0000000..dcc0114
--- /dev/null
+++ b/bin/inventory_manager.py
@@ -0,0 +1,162 @@
+#!/usr/bin/env python
+
+import os
+import sys
+import gobject
+import dbus
+import dbus.service
+import dbus.mainloop.glib
+import cPickle
+import json
+
+if (len(sys.argv) < 2):
+	print "Usage:  inventory_manager.py [system name]"
+	exit(1)
+System = __import__(sys.argv[1])
+import Openbmc
+
+DBUS_NAME = 'org.openbmc.managers.Inventory'
+OBJ_NAME = '/org/openbmc/managers/Inventory'
+FRUS = System.FRU_INSTANCES
+FRU_PATH = System.FRU_PATH
+
+## accessor class to FRU data structure
+class Fru:
+	def __init__(self,fru):
+		## validation
+		if (FRUS.has_key(fru) == False):
+			# TODO: event log
+			raise Exception("Invalid FRU path: "+fru)
+		
+		self.fru = fru
+	
+	def getField(self,field):
+		if (FRUS[self.fru].has_key(field) == False):
+			# TODO: event log
+			raise Exception("Invalid field: "+field)
+			
+		return FRUS[self.fru][field]
+
+	def isFru(self):
+		return FRUS[self.fru]['fru']
+
+	def update(self,data):
+		for k in data.keys():
+			FRUS[self.fru][k] = data[k]
+
+	def isCached(self):
+		return True
+
+	def getCacheFilename(self):
+		global FRU_PATH
+		filename = FRU_PATH+self.fru.replace('/','.')
+		return filename
+	
+	def saveToCache(self):
+		if (self.isCached() == False):
+			return
+		print "Caching: "+self.fru
+		output = open(self.getCacheFilename(), 'wb')
+		## just pickle dict not whole object
+		print FRUS[self.fru]
+		cPickle.dump(FRUS[self.fru],output)
+		output.close()
+
+	def loadFromCache(self):
+		if (self.isCached() == False):
+			return;
+		## overlay with pickled data
+		filename=self.getCacheFilename()
+		if (os.path.isfile(filename)):
+			print "Loading from cache: "+filename
+			p = open(filename, 'rb')
+			data2 = cPickle.load(p)
+			for k in data2.keys():
+				FRUS[self.fru][k] = data2[k]
+
+	def __str__(self):	
+		r = "Fru: "+str(self.fru_id)+"\n"
+		for f in self.data.keys():
+			r = r+f+" = "+str(self.data[f])+"\n"
+		return r
+
+		
+
+class InventoryManager(dbus.service.Object):
+	def __init__(self,bus,name):
+		dbus.service.Object.__init__(self,bus,name)
+		
+		bus.add_signal_receiver(self.UpdateFruHandler,
+					signal_name = 'UpdateFru')
+
+		self.fru_db = {}
+		self.fru_id_lookup = {}
+		self.sensor_id_lookup = {}
+
+		for fru_path in FRUS.keys():
+			self.addFru(fru_path)
+			f = FRUS[fru_path]
+			if (f.has_key('fru_id')):
+				self.fru_id_lookup[f['fru_id']] = fru_path
+			if (f.has_key('sensor_id')):
+				self.sensor_id_lookup[f['sensor_id']] = fru_path
+
+			
+	def UpdateFruHandler(self,fru_id,data):
+		self.updateFru(fru_id,data)		
+
+	@dbus.service.method(DBUS_NAME,
+		in_signature='y', out_signature='s')	
+	def getFruSensor(self,sensor_id):
+		if (self.sensor_id_lookup.has_key(sensor_id) == False):
+			return ""
+		return self.sensor_id_lookup[sensor_id]
+		
+	def addFru(self,fru_path):
+		new_fru = Fru(fru_path)
+		new_fru.loadFromCache()
+		self.fru_db[fru_path] = new_fru
+				
+	@dbus.service.method(DBUS_NAME,
+		in_signature='ia{sv}', out_signature='')
+	def updateFruFromId(self,fru_id,data):
+		iid = int(fru_id)
+		if (self.fru_id_lookup.has_key(iid) == False):
+			# TODO: event log
+			print "fru id "+str(iid)+" not found"
+		else:
+			self.updateFru(self.fru_id_lookup[iid],data)
+		
+
+	@dbus.service.method(DBUS_NAME,
+		in_signature='sa{sv}', out_signature='')
+	def updateFru(self,fru_path,data):
+		## translate dbus data into basic data types
+		clean_data = {}
+		for k in data.keys():
+			d = Openbmc.DbusProperty(k,data[k])
+			clean_data[str(k)] = d.getBaseValue()
+
+		if (self.fru_db.has_key(fru_path)):
+			## update properties then save to cache
+			print "Updating FRU: "+fru_path
+			self.fru_db[fru_path].update(clean_data)
+			self.fru_db[fru_path].saveToCache()
+
+
+	@dbus.service.method(DBUS_NAME,
+		in_signature='', out_signature='a{sa{sv}}')
+	def getFrus(self):
+		return FRUS
+
+
+if __name__ == '__main__':
+    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+    bus = dbus.SessionBus()
+    name = dbus.service.BusName(DBUS_NAME,bus)
+    obj = InventoryManager(bus,OBJ_NAME)
+    mainloop = gobject.MainLoop()
+
+    print "Running Inventory Manager"
+    mainloop.run()
+
diff --git a/bin/ipmi_example.py b/bin/ipmi_example.py
new file mode 100644
index 0000000..a0c5a86
--- /dev/null
+++ b/bin/ipmi_example.py
@@ -0,0 +1,79 @@
+#!/usr/bin/env python
+
+import sys
+import subprocess
+import gobject
+import dbus
+import dbus.service
+import dbus.mainloop.glib
+import PropertyManager
+
+import Openbmc
+
+
+
+def getWatchdog():
+	obj =  bus.get_object('org.openbmc.watchdog.Host',
+			'/org/openbmc/watchdog/HostWatchdog_0')
+	intf = dbus.Interface(obj, 'org.openbmc.Watchdog' )
+	return intf
+
+def getChassisControl():
+	obj =  bus.get_object('org.openbmc.control.Chassis',
+			'/org/openbmc/control/Chassis')
+	intf = dbus.Interface(obj, 'org.openbmc.control.Chassis' )
+	return intf
+
+def prettyPrint(data):
+	for k in data.keys():
+		print k
+		for k2 in data[k].keys():
+			print "\t"+k2+" = "+str(data[k][k2])
+
+if __name__ == '__main__':
+ 	bus = dbus.SessionBus()
+	cmd = sys.argv[1]
+	data = None
+	ipmi_id = dbus.Byte(0)
+	if (len(sys.argv) > 2):
+		ipmi_id = dbus.Byte(int(sys.argv[2]))
+	if (len(sys.argv)>3):
+		data = sys.argv[3]
+
+	if (cmd == "poweron"):
+		intf = getChassisControl()
+		intf.powerOn()
+	elif (cmd == "poweroff"):
+		intf = getChassisControl()
+		intf.powerOff()
+	elif (cmd == "setsensor"):
+		intf_sens = Openbmc.getManagerInterface(bus,"Sensors")
+		intf_sens.setSensorFromId(ipmi_id,data)
+	elif (cmd == "getsensor"):
+		intf_sens = Openbmc.getManagerInterface(bus,"Sensors")
+		print intf_sens.getSensorFromId(ipmi_id)
+	elif (cmd == "getsensors"):
+		intf_sens = Openbmc.getManagerInterface(bus,"Sensors")
+		data = intf_sens.getSensors()
+		prettyPrint(data)
+	elif (cmd == "updatefru"):
+		intf_fru = Openbmc.getManagerInterface(bus,"Inventory")
+		intf_fru.updateFruFromId(ipmi_id,data)
+	elif (cmd == "getfrus"):
+		intf_fru = Openbmc.getManagerInterface(bus,"Inventory")
+		data = intf_fru.getFrus()
+		prettyPrint(data)
+	elif (cmd == "pokewatchdog"):
+		intf = self.getWatchdog()
+		intf.poke()
+	elif (cmd == "statewatchdog"):
+		intf = self.getWatchdog()
+		intf.start()
+	else:
+		print "Unsupported command"
+
+
+
+
+
+
diff --git a/bin/ipmi_manager.py b/bin/ipmi_manager.py
deleted file mode 100644
index 24c36f4..0000000
--- a/bin/ipmi_manager.py
+++ /dev/null
@@ -1,105 +0,0 @@
-#!/usr/bin/env python
-
-import sys
-import subprocess
-#from gi.repository import GObject
-import gobject
-import dbus
-import dbus.service
-import dbus.mainloop.glib
-import PropertyManager
-
-if (len(sys.argv) < 2):
-	print "Usage:  ipmi_manager.py [system name]"
-	exit(1)
-
-System = __import__(sys.argv[1])
-import Openbmc
-
-DBUS_NAME = 'org.openbmc.managers.Ipmi'
-OBJ_NAME = '/org/openbmc/managers/Ipmi'
-
-
-class IpmiManager(dbus.service.Object):
-	def __init__(self,bus,name):
-		dbus.service.Object.__init__(self,bus,name)
-
-	## IPMI commands
-	@dbus.service.method(DBUS_NAME,
-		in_signature='yv', out_signature='')
-	def setSensor(self,sensor_id,value):
-		intf_sens = Openbmc.getManagerInterface(bus,"Sensors")
-		intf_sens.setSensorFromId(sensor_id,value)
-
-	@dbus.service.method(DBUS_NAME,
-		in_signature='y', out_signature='v')
-	def getSensor(self,sensor_id):
-		intf_sens = Openbmc.getManagerInterface(bus,"Sensors")
-		return intf_sens.getSensorFromId(sensor_id)
-
-	@dbus.service.method(DBUS_NAME,
-		in_signature='ia{sv}', out_signature='')
-	def updateFru(self,fru_id,data):
-		intf_fru = Openbmc.getManagerInterface(bus,"Frus")
-		intf_fru.updateFru(fru_id,data)
-
-	@dbus.service.method(DBUS_NAME,
-		in_signature='', out_signature='s')
-	def getFrus(self):
-		intf_fru = Openbmc.getManagerInterface(bus,"Frus")
-		return intf_fru.getFrus()
-
-
-	@dbus.service.method(DBUS_NAME,
-		in_signature='', out_signature='')
-	def pokeHostWatchdog(self):
-		## TODO don't do hardcoding
-		obj =  bus.get_object('org.openbmc.watchdog.Host',
-				'/org/openbmc/watchdog/HostWatchdog_0')
-		intf = dbus.Interface(obj, 'org.openbmc.Watchdog' )
-		intf.poke()
-		return None
-
-	@dbus.service.method(DBUS_NAME,
-		in_signature='', out_signature='')
-	def startHostWatchdog(self):
-		## TODO don't do hardcoding
-		obj =  bus.get_object('org.openbmc.watchdog.Host',
-				'/org/openbmc/watchdog/HostWatchdog_0')
-		intf = dbus.Interface(obj, 'org.openbmc.Watchdog' )
-		intf.start()
-		return None
-
-	@dbus.service.method(DBUS_NAME,
-		in_signature='', out_signature='')
-	def powerOn(self):
-		## TODO don't do hardcoding
-		obj =  bus.get_object('org.openbmc.control.Chassis',
-				'/org/openbmc/control/Chassis')
-		intf = dbus.Interface(obj, 'org.openbmc.control.Chassis' )
-		intf.powerOn()
-		return None
-
-	@dbus.service.method(DBUS_NAME,
-		in_signature='', out_signature='')
-	def powerOff(self):
-		## TODO don't do hardcoding
-		obj =  bus.get_object('org.openbmc.control.Chassis',
-				'/org/openbmc/control/Chassis')
-		intf = dbus.Interface(obj, 'org.openbmc.control.Chassis' )
-		intf.powerOff()
-		return None
-
-
-
-
-if __name__ == '__main__':
-    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
-    bus = dbus.SessionBus()
-    name = dbus.service.BusName(DBUS_NAME,bus)
-    obj = IpmiManager(bus,OBJ_NAME)
-    mainloop = gobject.MainLoop()
-
-    print "Running IpmiManager"
-    mainloop.run()
-
diff --git a/bin/ipmitool.py b/bin/ipmitool.py
deleted file mode 100644
index 973f071..0000000
--- a/bin/ipmitool.py
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/env python
-
-import sys
-import subprocess
-import dbus
-from gi.repository import GObject
-import dbus.service
-import dbus.mainloop.glib
-import Openbmc
-
-
-if __name__ == '__main__':
-	cmd = sys.argv[1]
-	data = None
-	ipmi_id = dbus.Byte(0)
-	if (len(sys.argv) > 2):
-		ipmi_id = dbus.Byte(int(sys.argv[2]))
-	if (len(sys.argv)>3):
-		data = sys.argv[3]
-
-	bus = dbus.SessionBus()
-	intf = Openbmc.getManagerInterface(bus,"Ipmi")
-
-	if (cmd == 'updatefru'):
-		d = { 'manufacturer' : data }
-		intf.updateFru(ipmi_id,d)
-	elif (cmd == 'getfrus'):
-		print intf.getFrus()
-	elif (cmd == 'setsensor'):
-		data_b = dbus.Byte(int(data))
-		intf.setSensor(ipmi_id,data_b)
-	elif (cmd == 'getsensor'):
-		print intf.getSensor(ipmi_id)
-	elif (cmd == 'pokewatchdog'):
-		print intf.pokeHostWatchdog()
-	elif (cmd == 'startwatchdog'):
-		print intf.startHostWatchdog()
-	elif (cmd == 'poweron'):
-		print intf.powerOn()
-	elif (cmd == 'poweroff'):
-		print intf.powerOff()
-	else:
-		print "ERROR: Invalid command"
-		print "Valid commands: updatefru, setsensor, getsensor, startwatchdog, pokewatchdog"		
-
-    #mainloop.run()
-
diff --git a/bin/sensor_manager.py b/bin/sensor_manager.py
index 9a193d6..4d8eccd 100644
--- a/bin/sensor_manager.py
+++ b/bin/sensor_manager.py
@@ -39,9 +39,7 @@
 
 	@dbus.service.method(DBUS_NAME,
 		in_signature='', out_signature='a{sa{sv}}')
-	def getSensorsAll(self):
-		## this is probably not ok
-		##sensors = []
+	def getSensors(self):
 		return self.sensor_cache;
 	
 	@dbus.service.method(DBUS_NAME,
@@ -56,6 +54,15 @@
 	@dbus.service.method(DBUS_NAME,
 		in_signature='yv', out_signature='')
 	def setSensorFromId(self,ipmi_id,value):
+		## first check if fru functional sensor
+		intf_inv = Openbmc.getManagerInterface(bus,"Inventory")
+		fru_path = intf_inv.getFruSensor(ipmi_id)
+		if (fru_path != ""):
+			data = { 'state': value }
+			intf_inv.updateFru(fru_path,data)
+			print "Found Fru Based Sensor: "+fru_path
+			return None
+
 		intf_sys = Openbmc.getManagerInterface(bus,"System")
 		obj_info = intf_sys.getObjFromIpmi(ipmi_id)
 		
diff --git a/bin/system_manager.py b/bin/system_manager.py
index 015aa8d..b852543 100644
--- a/bin/system_manager.py
+++ b/bin/system_manager.py
@@ -56,6 +56,14 @@
 
 
 	def SystemStateHandler(self,state_name):
+		print "Checking previous state started..."
+		i = 0
+		not_started=True
+		while(i<10 and not_started):
+			not_started = self.check_state_started()	
+			i=i+1
+			# add sleep	
+
 		print "Running System State: "+state_name
 		if (self.system_states.has_key(state_name)):
 			for bus_name in self.system_states[state_name]:
@@ -67,22 +75,23 @@
 		
 		if (System.ENTER_STATE_CALLBACK.has_key(state_name)):
 			cb = System.ENTER_STATE_CALLBACK[state_name]
-			obj = bus.get_object(cb['bus_name'],cb['obj_name'])
+			obj = bus.get_<F11>object(cb['bus_name'],cb['obj_name'])
 			method = obj.get_dbus_method(cb['method_name'],cb['interface_name'])
 			method()
 
-		current_state = state_name
+		self.current_state = state_name
 			
 	def start_process(self,bus_name):
 		if (System.SYSTEM_CONFIG[bus_name]['start_process'] == True):
 			process_name = System.BIN_PATH+System.SYSTEM_CONFIG[bus_name]['process_name']
 			cmdline = [ ]
 			cmdline.append(process_name)
+			System.SYSTEM_CONFIG[bus_name]['popen'] = None
 			for instance in System.SYSTEM_CONFIG[bus_name]['instances']:
 				cmdline.append(instance['name'])
 			try:
 				print "Starting process: "+" ".join(cmdline)+": "+bus_name
-				System.SYSTEM_CONFIG[bus_name]['popen'] = subprocess.Popen(cmdline);
+				System.SYSTEM_CONFIG[bus_name]['popen'] = subprocess.Popen(cmdline)
 			except Exception as e:
 				## TODO: error
 				print "Error starting process: "+" ".join(cmdline)
@@ -124,13 +133,26 @@
 		#print "Heartbeat seen: "+bus_name
 		System.SYSTEM_CONFIG[bus_name]['heartbeat_count']=1	
 
+	def check_state_started(self):
+		r = True
+		if (self.current_state == ""):
+			return True
+		for bus_name in self.system_states[self.current_state]:
+			if (System.SYSTEM_CONFIG[bus_name].has_key('popen') == False and
+				System.SYSTEM_CONFIG[bus_name]['start_process'] == True):
+				print "Not found: "+bus_name
+				r = False
+				break;	
+		return r
+	
+
 	def NewBusHandler(self, bus_name, a, b):
 		if (len(b) > 0 and bus_name.find(Openbmc.BUS_PREFIX) == 0):
 			if (System.SYSTEM_CONFIG.has_key(bus_name)):
 				System.SYSTEM_CONFIG[bus_name]['heartbeat_count'] = 0
 				objects = {}
-				Openbmc.get_objs(bus,bus_name,Openbmc.OBJ_PREFIX,objects)
-					
+				Openbmc.get_objs(bus,bus_name,Openbmc.OBJ_PREFIX,objects)				
+	
 				for instance_name in objects.keys(): 
 					obj_path = objects[instance_name]['PATH']
 					for instance in System.SYSTEM_CONFIG[bus_name]['instances']: