Merge pull request #29305 from lorengordon/source_hash_protos

Add 'file' as a source_hash proto
This commit is contained in:
Mike Place 2015-12-01 10:39:37 -07:00
commit 027bed7c90

View file

@ -3342,7 +3342,7 @@ def get_managed(
if not source_sum:
return '', {}, 'Source file {0} not found'.format(source)
elif source_hash:
protos = ('salt', 'http', 'https', 'ftp', 'swift', 's3')
protos = ('salt', 'http', 'https', 'ftp', 'swift', 's3', 'file')
if _urlparse(source_hash).scheme in protos:
# The source_hash is a file on a server
hash_fn = __salt__['cp.cache_file'](source_hash, saltenv)
@ -3351,18 +3351,19 @@ def get_managed(
source_hash)
source_sum = extract_hash(hash_fn, '', name)
if source_sum is None:
return '', {}, ('Source hash file {0} contains an invalid '
'hash format, it must be in the format <hash type>=<hash>.'
).format(source_hash)
return '', {}, ('Source hash {0} format is invalid. It '
'must be in the format, <hash type>=<hash>, or it '
'must be a supported protocol: {1}'
).format(source_hash, ', '.join(protos))
else:
# The source_hash is a hash string
comps = source_hash.split('=')
if len(comps) < 2:
return '', {}, ('Source hash file {0} contains an '
'invalid hash format, it must be in '
'the format <hash type>=<hash>'
).format(source_hash)
return '', {}, ('Source hash {0} format is invalid. It '
'must be in the format, <hash type>=<hash>, or it '
'must be a supported protocol: {1}'
).format(source_hash, ', '.join(protos))
source_sum['hsum'] = comps[1].strip()
source_sum['hash_type'] = comps[0].strip()
elif urlparsed_source.scheme == 'file':