def copy(self, resource, _from, _to, use_sudo=False): log.debug("TORRENT: %s -> %s", _from, _to) executor = Executor(resource=resource, executor=None, params=(_from, _to, use_sudo)) self.executors.append(executor)
def copy(self, resource, _from, _to, use_sudo=False): log.debug("RSYNC: %s -> %s", _from, _to) if use_sudo: rsync_path = "sudo rsync" else: rsync_path = "rsync" rsync_props = self._rsync_props(resource) rsync_cmd = ('rsync -az -e "ssh -i %(ssh_key)s" ' '--rsync-path="%(rsync_path)s" %(_from)s ' '%(rsync_host)s:%(_to)s') % dict( rsync_path=rsync_path, ssh_key=rsync_props['ssh_key'], rsync_host=rsync_props['host_string'], _from=_from, _to=_to) rsync_executor = lambda transport: fabric_api.local( rsync_cmd ) log.debug("RSYNC CMD: %r" % rsync_cmd) executor = Executor(resource=resource, executor=rsync_executor, params=(_from, _to, use_sudo)) self.executors.append(executor)
def copy(self, resource, _from, _to, use_sudo=False): log.debug("Solard copy: %s -> %s", _from, _to) client = self.get_client(resource) executor = lambda transport: client.copy(_from, _to, use_sudo) executor = Executor(resource=resource, executor=executor, params=(_from, _to, use_sudo)) self.executors.append(executor)
def copy(self, resource, _from, _to, use_sudo=False): log.debug('SCP: %s -> %s', _from, _to) if os.path.isfile(_from): executor = self._copy_file(resource, _from, _to, use_sudo) else: executor = self._copy_directory(resource, _from, _to, use_sudo) # with fabric_api.settings(**self._fabric_settings(resource)): # return executor() executor = Executor(resource=resource, executor=executor, params=(_from, _to, use_sudo)) self.executors.append(executor)
def copy(self, resource, _from, _to, use_sudo=False): log.debug("RSYNC: %s -> %s", _from, _to) if os.path.isdir(_from): r_dir_path = _to else: r_dir_path = _to.rsplit('/', 1)[0] if use_sudo: rsync_path = "sudo mkdir -p {} && sudo rsync".format(r_dir_path) else: rsync_path = "mkdir -p {} && rsync".format(r_dir_path) rsync_props = self._rsync_props(resource) ssh_cmd = ' '.join(self._ssh_cmd(rsync_props)) rsync_cmd = ('rsync -az -e "%(ssh_cmd)s" ' '--rsync-path="%(rsync_path)s" %(_from)s ' '%(rsync_host)s:%(_to)s') % dict( rsync_path=rsync_path, ssh_cmd=ssh_cmd, rsync_host=rsync_props['host_string'], _from=_from, _to=_to) if rsync_props.get('ssh_password'): env = os.environ.copy() env['SSHPASS'] = rsync_props['ssh_password'] else: env = os.environ rsync_executor = lambda transport: execute( rsync_cmd, shell=True, env=env) log.debug("RSYNC CMD: %r" % rsync_cmd) executor = Executor(resource=resource, executor=rsync_executor, params=(_from, _to, use_sudo)) self.executors.append(executor)