diff options
author | 2019-11-21 12:56:51 +0800 | |
---|---|---|
committer | 2019-11-21 12:58:52 +0800 | |
commit | 9003bbf2d379d446bf1c08ebd11a4c591be097ed (patch) | |
tree | f06264d17de7ee931cf08bb442e26cd207ea7c0a /vnfsdk_pkgtools | |
parent | 7897b7abd305cf079c6bc973f0fcb804d989a96f (diff) |
Correct hash algorithm name in the manifest file
Change-Id: I3817a296ec4480a18ee39f95f283062fa79d0cbf
Issue-ID: VNFSDK-518
Signed-off-by: Lianhao Lu <lianhao.lu@intel.com>
Diffstat (limited to 'vnfsdk_pkgtools')
-rw-r--r-- | vnfsdk_pkgtools/cli/__main__.py | 3 | ||||
-rw-r--r-- | vnfsdk_pkgtools/packager/manifest.py | 2 | ||||
-rw-r--r-- | vnfsdk_pkgtools/packager/utils.py | 4 |
3 files changed, 7 insertions, 2 deletions
diff --git a/vnfsdk_pkgtools/cli/__main__.py b/vnfsdk_pkgtools/cli/__main__.py index 09896e0..175fcb2 100644 --- a/vnfsdk_pkgtools/cli/__main__.py +++ b/vnfsdk_pkgtools/cli/__main__.py @@ -24,6 +24,7 @@ import tempfile import pkg_resources from vnfsdk_pkgtools.packager import csar +from vnfsdk_pkgtools.packager import manifest from vnfsdk_pkgtools import validator from vnfsdk_pkgtools import vnfreq @@ -99,7 +100,7 @@ def parse_args(args_list): help='Directory containing license information, relative to service template directory') csar_create.add_argument( '--digest', - choices=['SHA256', 'SHA512'], + choices=manifest.SUPPORTED_HASH_ALGO, help='If present, means to check the file deigest in manifest; compute the digest using the specified hash algorithm of all files in the csar package to be put into the manifest file') csar_create.add_argument( '--certificate', diff --git a/vnfsdk_pkgtools/packager/manifest.py b/vnfsdk_pkgtools/packager/manifest.py index 81ac53c..b2d0804 100644 --- a/vnfsdk_pkgtools/packager/manifest.py +++ b/vnfsdk_pkgtools/packager/manifest.py @@ -27,7 +27,7 @@ METADATA_KEYS = [ 'vnf_provider_id', 'vnf_release_data_time', 'vnf_package_version'] DIGEST_KEYS = [ 'Source', 'Algorithm', 'Hash' ] -SUPPORTED_HASH_ALGO = ['SHA256', 'SHA512'] +SUPPORTED_HASH_ALGO = ['SHA-256', 'SHA-512'] class ManifestException(Exception): pass diff --git a/vnfsdk_pkgtools/packager/utils.py b/vnfsdk_pkgtools/packager/utils.py index 405a65e..06143c6 100644 --- a/vnfsdk_pkgtools/packager/utils.py +++ b/vnfsdk_pkgtools/packager/utils.py @@ -40,6 +40,10 @@ def _hash_value_for_file(f, hash_function, block_size=2**20): def cal_file_hash(root, path, algo): + if algo == 'SHA-256': + algo = 'SHA256' + elif algo == 'SHA-512': + algo = 'SHA512' h = hashlib.new(algo) if urlparse.urlparse(path).scheme: r = requests.get(path) |