Add support for parsing host keyvals into the test attributes. The
host keyval data is pulled in as host-$KEY (i.e. labels is pulled
in as host-labels).

They're created by the scheduler. It puts them in the job results
directory, in a host_keyvals directory, one for each host. We use them
for recording extra information about hosts that only the scheduler is
aware of (e.g. labels). The parsing treats them as completely
optional, so obviously people not using the scheduler won't see any
actual changes.

Obviously it would be nice if TKO could just access this information
directly in the frontend database, but they databases are separate and
we aren't really eager to make TKO depend on the frontend. Plus, it
actually has some advantages, e.g. we record the host data at the time
the tests were run, whereas if we accessed the frontend db we're only
seeing the current host information.

Risk: Low
Visibility: Host data will be pulled in as test attributes.

Signed-off-by: John Admanski <jadmanski@google.com>



git-svn-id: http://test.kernel.org/svn/autotest/trunk@2126 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/tko/db.py b/tko/db.py
index df91103..08a0e00 100644
--- a/tko/db.py
+++ b/tko/db.py
@@ -242,7 +242,7 @@
                 self.con.commit()
 
 
-    def insert(self, table, data, commit = None):
+    def insert(self, table, data, commit=None):
         """\
                 'insert into table (keys) values (%s ... %s)', values
 
@@ -339,6 +339,10 @@
         if hasattr(test, "test_idx"):
             test_idx = test.test_idx
             self.update('tests', data, {'test_idx': test_idx}, commit=commit)
+            where = {'test_idx': test_idx}
+            self.delete('iteration_result', where)
+            self.delete('iteration_attributes', where)
+            self.delete('test_attributes', where)
         else:
             self.insert('tests', data, commit=commit)
             test_idx = test.test_idx = self.get_last_autonumber_value()