summaryrefslogtreecommitdiffstats
path: root/dovetail/report.py
diff options
context:
space:
mode:
authorStamatis Katsaounis <mokats@intracom-telecom.com>2019-02-19 12:38:10 +0200
committerDan Xu <xudan16@huawei.com>2019-03-13 10:48:45 +0000
commitb4e6a756ebeb019048cb03a0562534870b772cae (patch)
tree19035c5e15dbe4b227a76e3deaeffbd68afeb68f /dovetail/report.py
parent0856c3ab2083ed8b8f16572c0f0b249aab203e69 (diff)
Calculate checksum for input VNF
This patch adds checksum information inside ONAP related test case run results. The checksum is produced by the VNF input which can either be a CSAR file or an archive of Heat templates. Change-Id: I0ed58bdc9cc4031da08fd2ac220ef294520ef447 Signed-off-by: Stamatis Katsaounis <mokats@intracom-telecom.com>
Diffstat (limited to 'dovetail/report.py')
-rw-r--r--dovetail/report.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/dovetail/report.py b/dovetail/report.py
index 86f941df..556fc76d 100644
--- a/dovetail/report.py
+++ b/dovetail/report.py
@@ -12,6 +12,7 @@
from __future__ import division
import collections
+import hashlib
import json
import re
import os
@@ -70,6 +71,25 @@ class Report(object):
if checker is not None:
checker.check(testcase, db_result)
+ @staticmethod
+ def get_checksum(vnf_type):
+ if vnf_type == 'tosca':
+ path = os.path.join(dt_cfg.dovetail_config['config_dir'],
+ os.getenv('CSAR_FILE'))
+ elif vnf_type == 'heat':
+ path = os.path.join(
+ dt_cfg.dovetail_config['config_dir'],
+ os.getenv('VNF_ARCHIVE_NAME') + '.tar.gz')
+
+ checksum = hashlib.sha256()
+
+ if os.path.isfile(path):
+ with open(path, 'rb') as f:
+ for chunk in iter(lambda: f.read(4096), b''):
+ checksum.update(chunk)
+
+ return checksum.hexdigest()
+
def generate_json(self, testcase_list, duration):
report_obj = {}
# egeokun: using a hardcoded string instead of pbr version for
@@ -83,6 +103,7 @@ class Report(object):
vnf_type = dt_cfg.dovetail_config.get('vnf_type')
if vnf_type:
report_obj['vnf_type'] = vnf_type
+ report_obj['vnf_checksum'] = self.get_checksum(vnf_type)
report_obj['testcases_list'] = []
if not testcase_list: