From 2cb1daa1c0b09153ba98d35655998db97ddcfcbf Mon Sep 17 00:00:00 2001 From: Mike Place Date: Tue, 19 Aug 2014 10:32:01 -0600 Subject: [PATCH] Cleanup cp.push and file_recv_max_size options --- salt/config.py | 2 ++ salt/daemons/masterapi.py | 2 +- salt/master.py | 2 +- salt/modules/cp.py | 6 +++--- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/salt/config.py b/salt/config.py index 9b6dc2dedb..9fd7401779 100644 --- a/salt/config.py +++ b/salt/config.py @@ -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, diff --git a/salt/daemons/masterapi.py b/salt/daemons/masterapi.py index 251ae2c761..53c8cb8413 100644 --- a/salt/daemons/masterapi.py +++ b/salt/daemons/masterapi.py @@ -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') diff --git a/salt/master.py b/salt/master.py index 9224c42ba4..401951d789 100644 --- a/salt/master.py +++ b/salt/master.py @@ -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') diff --git a/salt/modules/cp.py b/salt/modules/cp.py index aacb8c7e16..da94e55527 100644 --- a/salt/modules/cp.py +++ b/salt/modules/cp.py @@ -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