Cleanup cp.push and file_recv_max_size options

This commit is contained in:
Mike Place 2014-08-19 10:32:01 -06:00
parent 3644f4f476
commit 2cb1daa1c0
4 changed files with 7 additions and 5 deletions

View File

@ -189,6 +189,7 @@ VALID_OPTS = {
'external_auth': dict,
'token_expire': int,
'file_recv': bool,
'file_recv_max_size': int,
'file_ignore_regex': bool,
'file_ignore_glob': bool,
'fileserver_backend': list,
@ -439,6 +440,7 @@ DEFAULT_MASTER_OPTS = {
'external_auth': {},
'token_expire': 43200,
'file_recv': False,
'file_recv_max_size': 100,
'file_buffer_size': 1048576,
'file_ignore_regex': None,
'file_ignore_glob': None,

View File

@ -598,7 +598,7 @@ class RemoteFuncs(object):
return False
if not salt.utils.verify.valid_id(self.opts, load['id']):
return False
file_recv_max_size = 1024*1024 * self.opts.get('file_recv_max_size', 100)
file_recv_max_size = 1024*1024 * self.opts['file_recv_max_size']
if 'loc' in load and load['loc'] < 0:
log.error('Invalid file pointer: load[loc] < 0')

View File

@ -952,7 +952,7 @@ class AESFuncs(object):
return False
if not salt.utils.verify.valid_id(self.opts, load['id']):
return False
file_recv_max_size = 1024*1024 * self.opts.get('file_recv_max_size', 100)
file_recv_max_size = 1024*1024 * self.opts['file_recv_max_size']
if 'loc' in load and load['loc'] < 0:
log.error('Invalid file pointer: load[loc] < 0')

View File

@ -655,17 +655,17 @@ def push(path):
'path': path.lstrip(os.sep),
'tok': auth.gen_token('salt')}
sreq = salt.transport.Channel.factory(__opts__)
# sreq = salt.payload.SREQ(__opts__['master_uri'])
with salt.utils.fopen(path, 'rb') as fp_:
while True:
load['loc'] = fp_.tell()
load['data'] = fp_.read(__opts__['file_buffer_size'])
if not load['data']:
return True
# ret = sreq.send('aes', auth.crypticle.dumps(load))
ret = sreq.send(load)
if not ret:
log.error('cp.push Failed transfer failed. Ensure master has '
'\'file_recv\' set to \'True\' and that the file is not '
'larger than the \'file_recv_size_max\' setting on the master.')
return ret