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':
|
if url_data.scheme == 's3':
|
||||||
try:
|
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',
|
salt.utils.s3.query(method='GET',
|
||||||
bucket=url_data.netloc,
|
bucket=url_data.netloc,
|
||||||
path=url_data.path[1:],
|
path=url_data.path[1:],
|
||||||
return_bin=False,
|
return_bin=False,
|
||||||
local_file=dest,
|
local_file=dest,
|
||||||
action=None,
|
action=None,
|
||||||
key=self.opts.get('s3.key', None),
|
key=s3_opt('key'),
|
||||||
keyid=self.opts.get('s3.keyid', None),
|
keyid=s3_opt('keyid'),
|
||||||
service_url=self.opts.get('s3.service_url',
|
service_url=s3_opt('service_url'),
|
||||||
None),
|
verify_ssl=s3_opt('verify_ssl', True),
|
||||||
verify_ssl=self.opts.get('s3.verify_ssl',
|
location=s3_opt('location'))
|
||||||
True),
|
|
||||||
location=self.opts.get('s3.location',
|
|
||||||
None))
|
|
||||||
return dest
|
return dest
|
||||||
except Exception:
|
except Exception as exc:
|
||||||
raise MinionError('Could not fetch from {0}'.format(url))
|
raise MinionError('Could not fetch from {0}. Exception: {1}'.format(url, exc))
|
||||||
if url_data.scheme == 'ftp':
|
if url_data.scheme == 'ftp':
|
||||||
try:
|
try:
|
||||||
ftp = ftplib.FTP(url_data.hostname)
|
ftp = ftplib.FTP(url_data.hostname)
|
||||||
|
Loading…
Reference in New Issue
Block a user