mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Reading S3 credentials from Pillar
This commit is contained in:
parent
a3216f813d
commit
9e5c16d4da
@ -554,23 +554,29 @@ 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)
|
||||
|
Loading…
Reference in New Issue
Block a user