Merge remote branch 'upstream/develop' into develop

This commit is contained in:
Forrest Alvarez 2014-01-13 05:31:44 +00:00
commit 39d9064811
3 changed files with 20 additions and 13 deletions

View File

@ -192,7 +192,7 @@
# A value of 10 minutes is a reasonable default.
#
# If the value is set to zero, this check is disabled.
#grains_refresh_every = 1
#grains_refresh_every: 1
# When healing, a dns_check is run. This is to make sure that the originally
# resolved dns has not changed. If this is something that does not happen in

View File

@ -18,8 +18,9 @@
'''
# Import Python Libs
import urllib2
import contextlib
import socket
import urllib2
# Import salt libs
from salt.utils.validate.net import ipv4_addr as _ipv4_addr
@ -40,7 +41,9 @@ def external_ip():
if not _ipv4_addr(ip_):
continue
return {'external_ip': ip_}
except (urllib2.HTTPError, urllib2.URLError):
except (urllib2.HTTPError,
urllib2.URLError,
socket.timeout):
continue
# Return an empty value as a last resort

View File

@ -2126,7 +2126,8 @@ def extract_hash(hash_fn, hash_type='md5', file_name=''):
source_sum = None
partial_id = False
name_sought = re.findall(r'^(.+)/([^/]+)$', '/x' + file_name)[0][1]
log.debug('modules.file.py - extract_hash(): Extracting hash for file named: {}'.format(name_sought))
log.debug('modules.file.py - extract_hash(): Extracting hash for file '
'named: {0}'.format(name_sought))
hash_fn_fopen = salt.utils.fopen(hash_fn, 'r')
for hash_variant in HASHES:
if hash_type == '' or hash_type == hash_variant[0]:
@ -2136,26 +2137,29 @@ def extract_hash(hash_fn, hash_type='md5', file_name=''):
hash_fn_fopen.seek(0)
for line in hash_fn_fopen.read().splitlines():
hash_array = re.findall(r'(?i)(?<![a-z0-9])[a-f0-9]{' + str(hash_variant[1]) + '}(?![a-z0-9])', line)
log.debug('modules.file.py - extract_hash(): '
'From "line": {} got : {}'.format(line, hash_array))
log.debug('modules.file.py - extract_hash(): From "line": {0} '
'got : {1}'.format(line, hash_array))
if hash_array:
if not partial_id:
source_sum = {'hsum': hash_array[0], 'hash_type': hash_variant[0]}
partial_id = True
log.debug('modules.file.py - extract_hash(): Found : {} -- {}'.format(
source_sum['hash_type'], source_sum['hsum']))
log.debug('modules.file.py - extract_hash(): Found: {0} '
'-- {1}'.format(source_sum['hash_type'],
source_sum['hsum']))
if re.search(name_sought, line):
source_sum = {'hsum': hash_array[0], 'hash_type': hash_variant[0]}
log.debug('modules.file.py - extract_hash: '
'For {} -- returning the {} hash "{}".'.format(
name_sought, source_sum['hash_type'], source_sum['hsum']))
log.debug('modules.file.py - extract_hash: For {0} -- '
'returning the {1} hash "{2}".'.format(
name_sought,
source_sum['hash_type'],
source_sum['hsum']))
return source_sum
if partial_id:
log.debug('modules.file.py - extract_hash: '
'Returning the partially identified {} hash "{}".'.format(
log.debug('modules.file.py - extract_hash: Returning the partially '
'identified {0} hash "{1}".'.format(
source_sum['hash_type'], source_sum['hsum']))
else:
log.debug('modules.file.py - extract_hash: Returning None.')