From: Ondrej Lichtner <olichtne(a)redhat.com>
This method computes a sha1 hash of the PerfRepoTestExecution object.
this hash can be used as an id for mapping to report ids while we don't
have a better solution. The hash is computed from the objects parameters
and tags that are ordered to ensure determinism between runs.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Controller/Task.py | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/lnst/Controller/Task.py b/lnst/Controller/Task.py
index e69c348..ccbd299 100644
--- a/lnst/Controller/Task.py
+++ b/lnst/Controller/Task.py
@@ -10,6 +10,7 @@ __author__ = """
rpazdera(a)redhat.com (Radek Pazdera)
"""
+import hashlib
from lnst.Controller.PerfRepo import PerfRepoRESTAPI
from lnst.Controller.PerfRepo import PerfRepoTestExecution
from lnst.Controller.PerfRepo import PerfRepoValue
@@ -575,3 +576,15 @@ class PerfRepoResult(object):
def get_testExecution(self):
return self._testExecution
+
+ def generate_hash(self):
+ tags = self._testExecution.get_tags()
+ params = self._testExecution.get_parameters()
+
+ sha1 = hashlib.sha1()
+ for i in sorted(tags):
+ sha1.update(i)
+ for i in sorted(params, key=lambda x: x[0]):
+ sha1.update(i[0])
+ sha1.update(i[1])
+ return sha1.hexdigest()
--
2.1.0