mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #29011 from rallytime/bp-28630
Back-port #28630 to 2015.5
This commit is contained in:
commit
a2e4a227e0
2 changed files with 21 additions and 14 deletions
|
@ -554,23 +554,30 @@ class Client(object):
|
|||
|
||||
if url_data.scheme == 's3':
|
||||
try:
|
||||
import salt.utils.s3
|
||||
|
||||
def s3_opt(key, default=None):
|
||||
'''Get value of s3.<key> from Minion config or from Pillar'''
|
||||
if 's3.' + key in self.opts:
|
||||
return self.opts['s3.' + key]
|
||||
try:
|
||||
return self.opts['pillar']['s3'][key]
|
||||
except (KeyError, TypeError):
|
||||
return default
|
||||
salt.utils.s3.query(method='GET',
|
||||
bucket=url_data.netloc,
|
||||
path=url_data.path[1:],
|
||||
return_bin=False,
|
||||
local_file=dest,
|
||||
action=None,
|
||||
key=self.opts.get('s3.key', None),
|
||||
keyid=self.opts.get('s3.keyid', None),
|
||||
service_url=self.opts.get('s3.service_url',
|
||||
None),
|
||||
verify_ssl=self.opts.get('s3.verify_ssl',
|
||||
True),
|
||||
location=self.opts.get('s3.location',
|
||||
None))
|
||||
key=s3_opt('key'),
|
||||
keyid=s3_opt('keyid'),
|
||||
service_url=s3_opt('service_url'),
|
||||
verify_ssl=s3_opt('verify_ssl', True),
|
||||
location=s3_opt('location'))
|
||||
return dest
|
||||
except Exception:
|
||||
raise MinionError('Could not fetch from {0}'.format(url))
|
||||
except Exception as exc:
|
||||
raise MinionError('Could not fetch from {0}. Exception: {1}'.format(url, exc))
|
||||
if url_data.scheme == 'ftp':
|
||||
try:
|
||||
ftp = ftplib.FTP(url_data.hostname)
|
||||
|
|
|
@ -122,10 +122,10 @@ def query(key, keyid, method='GET', params=None, headers=None,
|
|||
verify=verify_ssl)
|
||||
response = result.content
|
||||
except requests.exceptions.HTTPError as exc:
|
||||
log.error('There was an error::')
|
||||
if hasattr(exc, 'code') and hasattr(exc, 'msg'):
|
||||
log.error(' Code: {0}: {1}'.format(exc.code, exc.msg))
|
||||
log.error(' Content: \n{0}'.format(exc.read()))
|
||||
log.error('Failed to {0} {1}::'.format(method, requesturl))
|
||||
log.error(' Exception: {0}'.format(exc))
|
||||
if exc.response:
|
||||
log.error(' Response content: {0}'.format(exc.response.content))
|
||||
return False
|
||||
|
||||
log.debug('S3 Response Status Code: {0}'.format(result.status_code))
|
||||
|
|
Loading…
Add table
Reference in a new issue