def syncup_project(): """ Allows to explicitly initiate syncing for a project. """ project_id = request.args.get('id') if project_id: job = scheduler.get_job(job_id=project_id) rsync_host = job.kwargs['rsync_host'] rsync_module = job.kwargs['rsync_module'] project = job.kwargs['project'] dest = '%s/%s' % (job.kwargs['dest'], project) password = job.kwargs['rsync_password'] rsync_options = job.kwargs['rsync_options'] full_source = '%s@%s::%s' % (project, rsync_host, rsync_module) rsync_call_nonblocking(full_source, dest, password, rsync_options['basic'], rsync_options['defaults'], rsync_options['delete']) return jsonify({'method': 'syncup_project', 'success': True, 'project_id': projec_id, 'note': 'sync initiated'}) else: return jsonify({'method': 'syncup_project', 'success': False, 'note': 'No project id provided'})
def sync_project_from_upstream(): """ An API endpoint that is used by the master to tell the slave nodes to sync from it. """ details = request.json # source = details['source'] project = details['project'] rsync_password = details['rsync_password'] rsync_options = details['rsync_options'] slave_id = details['slave_id'] full_source = '%s@%s::%s/%s' % (app.config['SLAVE_USER'], master_hostname, \ app.config['MASTER_RSYNCD_MODULE'], project) print('I am syncing up -%s- using rsync source: %s' % (project, full_source,)) dest = app.config['SLAVE_PUBLIC_DIR'] # Pull the data from the master node via rsync rsync_call_nonblocking(full_source, dest, rsync_password, rsync_options['basic'], rsync_options['defaults'], rsync_options['delete'],) print('I have completed syncing of -%s- from master node' % (project,)) # As soon as rsync completes we could hit another endpoint on the master # node to inform it that *so and so* slave node has completed rsync. inform_master_sync_complete(slave_id, project) return jsonify({'success': True, 'details': 'Rsync call initiated on all slave nodes' })
def sync_project_from_upstream(): """ An API endpoint that is used by the master to tell the slave nodes to sync from it. """ details = request.json # source = details['source'] project = details['project'] rsync_password = details['rsync_password'] rsync_options = details['rsync_options'] slave_id = details['slave_id'] full_source = '%s@%s::%s/%s' % (app.config['SLAVE_USER'], master_hostname, \ app.config['MASTER_RSYNCD_MODULE'], project) print('I am syncing up -%s- using rsync source: %s' % ( project, full_source, )) dest = app.config['SLAVE_PUBLIC_DIR'] # Pull the data from the master node via rsync rsync_call_nonblocking( full_source, dest, rsync_password, rsync_options['basic'], rsync_options['defaults'], rsync_options['delete'], ) print('I have completed syncing of -%s- from master node' % (project, )) # As soon as rsync completes we could hit another endpoint on the master # node to inform it that *so and so* slave node has completed rsync. inform_master_sync_complete(slave_id, project) return jsonify({ 'success': True, 'details': 'Rsync call initiated on all slave nodes' })