From d45d0265651cd6582bbaf30670a24cd3d9ee76e0 Mon Sep 17 00:00:00 2001 From: Jedrzej Nowak Date: Thu, 8 Oct 2015 12:10:33 +0200 Subject: [PATCH] torrent transport resource improvements --- resources/transport_torrent/meta.yaml | 4 ++++ resources/transports/meta.yaml | 2 +- solar/solar/core/transports/torrent.py | 8 ++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/resources/transport_torrent/meta.yaml b/resources/transport_torrent/meta.yaml index 9eb5627e..217a5442 100644 --- a/resources/transport_torrent/meta.yaml +++ b/resources/transport_torrent/meta.yaml @@ -1,5 +1,9 @@ id: transport_torrent +handler: ansible input: + trackers: + schema: [str!] + value: [] name: schema: str! value: torrent diff --git a/resources/transports/meta.yaml b/resources/transports/meta.yaml index d73bb018..a691faed 100644 --- a/resources/transports/meta.yaml +++ b/resources/transports/meta.yaml @@ -1,7 +1,7 @@ id: transports input: transports: - schema: [{user: str, password: str, port: int!, key: str, name: str!}] + schema: [{user: str, password: str, port: int!, key: str, name: str!, trackers: [str]}] value: [] transports_id: schema: str! diff --git a/solar/solar/core/transports/torrent.py b/solar/solar/core/transports/torrent.py index cfaae4aa..31a0da05 100644 --- a/solar/solar/core/transports/torrent.py +++ b/solar/solar/core/transports/torrent.py @@ -64,15 +64,15 @@ class TorrentSyncTransport(SyncTransport): params=(_from, _to, use_sudo)) self.executors.append(executor) - def _create_single_torrent(self, _from, _to, use_sudo): + def _create_single_torrent(self, resource, _from, _to, use_sudo): fs = lt.file_storage() lt.add_files(fs, _from) - self._create_torrent(fs, _from) + self._create_torrent(resource, fs, _from) def _create_torrent_name(self): return os.path.join(self._torrent_path, uuid4().hex + '.torrent') - def _create_torrent(self, fs, root='.', use_sudo=False): + def _create_torrent(self, resource, fs, root='.', use_sudo=False): t = lt.create_torrent(fs) for tracker in TRACKERS: t.add_tracker(tracker) @@ -124,7 +124,7 @@ class TorrentSyncTransport(SyncTransport): def preprocess(self, executor): _from, _to, use_sudo = executor.params - self._create_single_torrent(_from, _to, use_sudo) + self._create_single_torrent(executor.resource, _from, _to, use_sudo) def run_all(self): self._start_seeding()