IPMI changes to mark non present as non functional

When marking a unit as functional, both functional state
and presence need to be checked to avoid marking non-present
units as functional.

Change-Id: If7b710c39f1c2590b82378ebdb7014dc924599ff
Signed-off-by: Dhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>
diff --git a/scripts/writesensor.mako.cpp b/scripts/writesensor.mako.cpp
index 9cd4e48..c5db13a 100644
--- a/scripts/writesensor.mako.cpp
+++ b/scripts/writesensor.mako.cpp
@@ -51,7 +51,7 @@
        if "readingAssertion" == valueReadingType or "readingData" == valueReadingType:
            for interface,properties in interfaces.items():
                for dbus_property,property_value in properties.items():
-                   for offset,values in property_value.items():
+                   for offset,values in property_value["Offsets"].items():
                        valueType = values["type"]
            updateFunc = "set::" + valueReadingType + "<" + valueType + ">"
            getFunc = "get::" + valueReadingType + "<" + valueType + ">"
@@ -66,7 +66,28 @@
             {"${interface}",{
             % for dbus_property,property_value in properties.items():
                 {"${dbus_property}",{
-                % for offset,values in property_value.items():
+<%
+try:
+    preReq = property_value["Prereqs"]
+except KeyError, e:
+    preReq = dict()
+%>\
+                {
+                    % for preOffset,preValues in preReq.items():
+                    { ${preOffset},{
+                        % for name,value in preValues.items():
+                            % if name == "type":
+<%                              continue %>\
+                            % endif
+<%                          value = str(value).lower() %>\
+                            ${value},
+                        % endfor
+                        }
+                    },
+                    % endfor
+                },
+                {
+                % for offset,values in property_value["Offsets"].items():
                     { ${offset},{
                         % if offset == 0xFF:
                             }},
@@ -102,11 +123,11 @@
                         }
                     },
                 % endfor
-                }},
+                }}},
             % endfor
             }},
     % endfor
-     },
+     }
 }},
    % endif
 % endfor