Merge pull request #111 from mdmillerii/flash-bmc

Flash bmc updates
diff --git a/configs/Barreleye.py b/configs/Barreleye.py
index 7b74179..6403ed6 100644
--- a/configs/Barreleye.py
+++ b/configs/Barreleye.py
@@ -405,8 +405,6 @@
 		'PRODUCT_0'  : '<inventory_root>/system/bios',
 		'BOARD_3'    : '<inventory_root>/system/misc',
 		'PRODUCT_51' : '<inventory_root>/system/misc',
-		'PRODUCT_100': '<inventory_root>/system',
-		'CHASSIS_100': '<inventory_root>/system/chassis',
 		'BOARD_100'  : '<inventory_root>/system/chassis/io_board',
 		'BOARD_101'  : '<inventory_root>/system/chassis/sas_expander',
 		'BOARD_102'  : '<inventory_root>/system/chassis/hdd_backplane',
diff --git a/pychassisctl/chassis_control.py b/pychassisctl/chassis_control.py
old mode 100644
new mode 100755
index 376e0e9..56a2116
--- a/pychassisctl/chassis_control.py
+++ b/pychassisctl/chassis_control.py
@@ -19,197 +19,221 @@
 
 BOOTED = 100
 
-class ChassisControlObject(DbusProperties,DbusObjectManager):
-	def getUuid(self):
-		uuid = "";
-		try:
-			with open(MACHINE_ID) as f:
-				data = f.readline().rstrip('\n')
-				if (len(data) == 32):
-					uuid = data
-				else:
-					print "ERROR:  UUID is not formatted correctly: "+data
-		except:
-			print "ERROR: Unable to open uuid file: "+MACHINE_ID
-				
-		return uuid
- 
-	def __init__(self,bus,name):
-		self.dbus_objects = { }
-		DbusProperties.__init__(self)
-		DbusObjectManager.__init__(self)
-		dbus.service.Object.__init__(self,bus,name)
-		## load utilized objects
-		self.dbus_objects = {
-			'power_control' : { 
-				'bus_name' : 'org.openbmc.control.Power',
-				'object_name' : '/org/openbmc/control/power0',
-				'interface_name' : 'org.openbmc.control.Power'
-			},
-			'identify_led' : {
-				'bus_name' : 'org.openbmc.control.led',
-				'object_name' : '/org/openbmc/control/led/identify',
-				'interface_name' : 'org.openbmc.Led'
-			},
-			'watchdog' : {				
-				'bus_name' : 'org.openbmc.watchdog.Host',
-				'object_name' : '/org/openbmc/watchdog/host0',
-				'interface_name' : 'org.openbmc.Watchdog'
-			},
-			'host_services' : {
-				'bus_name' : 'org.openbmc.HostServices',
-				'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",self.getUuid())
-		self.Set(DBUS_NAME,"reboot",0)
+class ChassisControlObject(DbusProperties, DbusObjectManager):
+    def getUuid(self):
+        uuid = "";
+        try:
+            with open(MACHINE_ID) as f:
+                data = f.readline().rstrip('\n')
+                if (len(data) == 32):
+                    uuid = data
+                else:
+                    print "ERROR:  UUID is not formatted correctly: " + data
+        except:
+            print "ERROR: Unable to open uuid file: " + MACHINE_ID
 
-		bus.add_signal_receiver(self.power_button_signal_handler, 
-					dbus_interface = "org.openbmc.Button", signal_name = "Released", 
-					path="/org/openbmc/buttons/power0" )
-		bus.add_signal_receiver(self.reset_button_signal_handler, 
-					dbus_interface = "org.openbmc.Button", signal_name = "PressedLong", 
-					path="/org/openbmc/buttons/power0" )
-		bus.add_signal_receiver(self.softreset_button_signal_handler, 
-					dbus_interface = "org.openbmc.Button", signal_name = "Released", 
-					path="/org/openbmc/buttons/reset0" )
+        return uuid
 
-    		bus.add_signal_receiver(self.host_watchdog_signal_handler, 
-					dbus_interface = "org.openbmc.Watchdog", signal_name = "WatchdogError")
+    def __init__(self, bus, name):
+        self.dbus_objects = {}
+        DbusProperties.__init__(self)
+        DbusObjectManager.__init__(self)
+        dbus.service.Object.__init__(self, bus, name)
+        ## load utilized objects
+        self.dbus_objects = {
+            'power_control': {
+                'bus_name': 'org.openbmc.control.Power',
+                'object_name': '/org/openbmc/control/power0',
+                'interface_name': 'org.openbmc.control.Power'
+            },
+            'identify_led': {
+                'bus_name': 'org.openbmc.control.led',
+                'object_name': '/org/openbmc/control/led/identify',
+                'interface_name': 'org.openbmc.Led'
+            },
+            'watchdog': {
+                'bus_name': 'org.openbmc.watchdog.Host',
+                'object_name': '/org/openbmc/watchdog/host0',
+                'interface_name': 'org.openbmc.Watchdog'
+            },
+            'host_services': {
+                'bus_name': 'org.openbmc.HostServices',
+                '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'
+            },
+            'host_control': {
+                'bus_name': 'org.openbmc.control.Host',
+                'object_name': '/org/openbmc/control/host0',
+                'interface_name': 'org.openbmc.control.Host'
+            },
+        }
 
-   		bus.add_signal_receiver(self.emergency_shutdown_signal_handler, 
-					dbus_interface = "org.openbmc.SensorThresholds", signal_name = "Emergency")
+        # uuid
+        self.Set(DBUS_NAME, "uuid", self.getUuid())
+        self.Set(DBUS_NAME, "reboot", 0)
 
-		bus.add_signal_receiver(self.SystemStateHandler,signal_name = "GotoSystemState")
-		self.InterfacesAdded(name,self.properties)
+        bus.add_signal_receiver(self.power_button_signal_handler,
+                                dbus_interface="org.openbmc.Button",
+                                signal_name="Released",
+                                path="/org/openbmc/buttons/power0")
+        bus.add_signal_receiver(self.reset_button_signal_handler,
+                                dbus_interface="org.openbmc.Button",
+                                signal_name="PressedLong",
+                                path="/org/openbmc/buttons/power0")
+        bus.add_signal_receiver(self.softreset_button_signal_handler,
+                                dbus_interface="org.openbmc.Button",
+                                signal_name="Released",
+                                path="/org/openbmc/buttons/reset0")
+
+        bus.add_signal_receiver(self.host_watchdog_signal_handler,
+                                dbus_interface="org.openbmc.Watchdog",
+                                signal_name="WatchdogError")
+
+        bus.add_signal_receiver(self.emergency_shutdown_signal_handler,
+                                dbus_interface="org.openbmc.SensorThresholds",
+                                signal_name="Emergency")
+
+        bus.add_signal_receiver(self.SystemStateHandler,
+                                signal_name="GotoSystemState")
+        self.InterfacesAdded(name, self.properties)
 
 
-	def getInterface(self,name):
-		o = self.dbus_objects[name]
-		obj = bus.get_object(o['bus_name'],o['object_name'],introspect=False)
-		return dbus.Interface(obj,o['interface_name'])
+    def getInterface(self, name):
+        o = self.dbus_objects[name]
+        obj = bus.get_object(o['bus_name'], o['object_name'], introspect=False)
+        return dbus.Interface(obj, o['interface_name'])
 
 
-	@dbus.service.method(DBUS_NAME,
-		in_signature='', out_signature='')
-	def setIdentify(self):
-		print "Turn on identify"
-		intf = self.getInterface('identify_led')
-		intf.setOn()	
-		return None
+    @dbus.service.method(DBUS_NAME,
+                         in_signature='', out_signature='')
+    def setIdentify(self):
+        print "Turn on identify"
+        intf = self.getInterface('identify_led')
+        intf.setOn()
+        return None
 
-	@dbus.service.method(DBUS_NAME,
-		in_signature='', out_signature='')
-	def clearIdentify(self):
-		print "Turn on identify"
-		intf = self.getInterface('identify_led')
-		intf.setOff()
-		return None
+    @dbus.service.method(DBUS_NAME,
+                         in_signature='', out_signature='')
+    def clearIdentify(self):
+        print "Turn on identify"
+        intf = self.getInterface('identify_led')
+        intf.setOff()
+        return None
 
-	@dbus.service.method(DBUS_NAME,
-		in_signature='', out_signature='')
-	def powerOn(self):
-		print "Turn on power and boot"
-		self.Set(DBUS_NAME,"reboot",0)
-		if (self.getPowerState()==0):
-			intf = self.getInterface('power_control')
-			intf.setPowerState(POWER_ON)
-			intfwatchdog = self.getInterface('watchdog')
-			#Start watchdog with 30s timeout per the OpenPower Host IPMI Spec
-			#Once the host starts booting, it'll reset and refresh the timer
-			intfwatchdog.set(30000)
-			intfwatchdog.start()
-		return None
+    @dbus.service.method(DBUS_NAME,
+                         in_signature='', out_signature='')
+    def powerOn(self):
+        print "Turn on power and boot"
+        self.Set(DBUS_NAME, "reboot", 0)
+        if (self.getPowerState() == 0):
+            intf = self.getInterface('power_control')
+            intf.setPowerState(POWER_ON)
 
-	@dbus.service.method(DBUS_NAME,
-		in_signature='', out_signature='')
-	def powerOff(self):
-		print "Turn off power"
-		intfwatchdog = self.getInterface('watchdog')
-		intfwatchdog.stop()
-		intf = self.getInterface('power_control')
-		intf.setPowerState(POWER_OFF)
-		return None
+            # Determine if debug_mode is set.  If it is then we don't
+            # want to start the watchdog since debug mode
+            intfcontrol = self.getInterface('host_control')
+            intfproperties = dbus.Interface(intfcontrol,
+                                            "org.freedesktop.DBus.Properties")
+            debug_mode = intfproperties.Get('org.openbmc.control.Host',
+                                            'debug_mode')
+            if(not debug_mode):
+                intfwatchdog = self.getInterface('watchdog')
+                # Start watchdog with 30s timeout per the OpenPower Host IPMI Spec
+                #Once the host starts booting, it'll reset and refresh the timer
+                intfwatchdog.set(30000)
+                intfwatchdog.start()
+            else:
+                print "Debug mode is on, no watchdog"
+        return None
 
-	@dbus.service.method(DBUS_NAME,
-		in_signature='', out_signature='')
-	def softPowerOff(self):
-		print "Soft off power"
-		intf = self.getInterface('host_services')
-		## host services will call power off when ready
-		intf.SoftPowerOff()
-		return None
+    @dbus.service.method(DBUS_NAME,
+                         in_signature='', out_signature='')
+    def powerOff(self):
+        print "Turn off power"
+        intfwatchdog = self.getInterface('watchdog')
+        intfwatchdog.stop()
+        intf = self.getInterface('power_control')
+        intf.setPowerState(POWER_OFF)
+        return None
 
-	@dbus.service.method(DBUS_NAME,
-		in_signature='', out_signature='')
-	def reboot(self):
-		print "Rebooting"
-		if self.getPowerState() == POWER_OFF:
-			self.powerOn();
-		else:
-			self.Set(DBUS_NAME,"reboot",1)
-			self.powerOff()
-		return None
+    @dbus.service.method(DBUS_NAME,
+                         in_signature='', out_signature='')
+    def softPowerOff(self):
+        print "Soft off power"
+        intf = self.getInterface('host_services')
+        ## host services will call power off when ready
+        intf.SoftPowerOff()
+        return None
 
-	@dbus.service.method(DBUS_NAME,
-		in_signature='', out_signature='')
-	def softReboot(self):
-		print "Soft Rebooting"
-		if self.getPowerState() == POWER_OFF:
-			self.powerOn();
-		else:
-			self.Set(DBUS_NAME,"reboot",1)
-			self.softPowerOff()
-		return None
+    @dbus.service.method(DBUS_NAME,
+                         in_signature='', out_signature='')
+    def reboot(self):
+        print "Rebooting"
+        if self.getPowerState() == POWER_OFF:
+            self.powerOn();
+        else:
+            self.Set(DBUS_NAME, "reboot", 1)
+            self.powerOff()
+        return None
 
-	@dbus.service.method(DBUS_NAME,
-		in_signature='', out_signature='i')
-	def getPowerState(self):
-		intf = self.getInterface('power_control')
-		return intf.getPowerState()
+    @dbus.service.method(DBUS_NAME,
+                         in_signature='', out_signature='')
+    def softReboot(self):
+        print "Soft Rebooting"
+        if self.getPowerState() == POWER_OFF:
+            self.powerOn();
+        else:
+            self.Set(DBUS_NAME, "reboot", 1)
+            self.softPowerOff()
+        return None
 
-	## Signal handler
+    @dbus.service.method(DBUS_NAME,
+                         in_signature='', out_signature='i')
+    def getPowerState(self):
+        intf = self.getInterface('power_control')
+        return intf.getPowerState()
 
-	def SystemStateHandler(self,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)
+    ## Signal handler
 
-		if (state_name == "HOST_POWERED_OFF" and self.Get(DBUS_NAME,"reboot")==1):
-			self.powerOn()
+    def SystemStateHandler(self, 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)
 
-	def power_button_signal_handler(self):
-		# toggle power
-		state = self.getPowerState()
-		if state == POWER_OFF:
-			self.powerOn()
-		elif state == POWER_ON:
-			self.powerOff();
+        if (state_name == "HOST_POWERED_OFF" and self.Get(DBUS_NAME,
+                                                          "reboot") == 1):
+            self.powerOn()
 
-	def reset_button_signal_handler(self):
-		self.reboot();
+    def power_button_signal_handler(self):
+        # toggle power
+        state = self.getPowerState()
+        if state == POWER_OFF:
+            self.powerOn()
+        elif state == POWER_ON:
+            self.powerOff();
 
-	def softreset_button_signal_handler(self):
-		self.softReboot();
-		
-	def host_watchdog_signal_handler(self):
-		print "Watchdog Error, Hard Rebooting"
-		self.Set(DBUS_NAME,"reboot",1)
-		self.powerOff()
+    def reset_button_signal_handler(self):
+        self.reboot();
 
-	def emergency_shutdown_signal_handler(self):
-		print "Emergency Shutdown!"
-		self.powerOff()
-		
-		
+    def softreset_button_signal_handler(self):
+        self.softReboot();
+
+    def host_watchdog_signal_handler(self):
+        print "Watchdog Error, Hard Rebooting"
+        self.Set(DBUS_NAME, "reboot", 1)
+        self.powerOff()
+
+    def emergency_shutdown_signal_handler(self):
+        print "Emergency Shutdown!"
+        self.powerOff()
+
 
 if __name__ == '__main__':
     dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
@@ -218,7 +242,7 @@
     name = dbus.service.BusName(DBUS_NAME, bus)
     obj = ChassisControlObject(bus, OBJ_NAME)
     mainloop = gobject.MainLoop()
-    
+
     print "Running ChassisControlService"
     mainloop.run()
 
diff --git a/pyhwmon/hwmon.py b/pyhwmon/hwmon.py
index e5dc19a..bb363dc 100644
--- a/pyhwmon/hwmon.py
+++ b/pyhwmon/hwmon.py
@@ -65,6 +65,7 @@
 				self.writeAttribute(attribute,rtn[1])
 		except:
 			print "HWMON: Attibute no longer exists: "+attribute
+			self.sensors.pop(objpath,None)
 			return False