Skip to content

Commit

Permalink
Merge pull request #83 from slohse/incoming-folder-ssh-params
Browse files Browse the repository at this point in the history
incoming folder: make user/key for move command configurable
  • Loading branch information
johandahlberg authored Oct 9, 2017
2 parents d64661f + de394b7 commit 97f9b25
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
3 changes: 3 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ runfolder_svc_urls:
incoming_svc_urls:
- url: http://testarteria1:10850/api/1.0/runfolders/next
dest_folder: /data/testarteria1/runfolders
remote_user: arteria
user_key: /home/arteria/.ssh/id_rsa


charon_api_token: dummy_token
charon_base_url: http://charon.url
Expand Down
3 changes: 2 additions & 1 deletion rules/mv_runfolders_from_incoming_to_processing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ action:
hosts: "{{ trigger.host }}"
source: "{{ trigger.runfolder }}"
destination: "{{ trigger.destination }}"

username: "{{ trigger.remote_user }}"
private_key: "{{ trigger.user_key }}"
7 changes: 6 additions & 1 deletion sensors/incoming_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ def setup(self):
try:
self._load_config()
client_urls = [x['url'] for x in self.config["incoming_svc_urls"]]
self._destinations = {x['url']: x['dest_folder'] for x in self.config["incoming_svc_urls"]}
# copy all further keys of every item over to self._hostconfigs
for x in self.config["incoming_svc_urls"]:
self._hostconfigs[x['url']] = {}
for y in x:
if y != 'url':
self._hostconfigs[x['url']][y] = x[y]
self._client = RunfolderClient(client_urls, self._logger)
self._infolog("Created client: {0}".format(self._client))
except Exception as ex:
Expand Down
5 changes: 5 additions & 0 deletions sensors/incoming_sensor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@
type: "string"
destination:
type: "string"
remote_user:
type: "string"
user_key:
type: "string"

8 changes: 5 additions & 3 deletions sensors/runfolder_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __init__(self, sensor_service, config=None, poll_interval=None, trigger='art
self._infolog("__init__")
self._client = None
self._trigger = trigger
self._destinations = {}
self._hostconfigs = {}

def setup(self):
self._infolog("setup")
Expand Down Expand Up @@ -66,8 +66,10 @@ def _handle_result(self, result):
'timestamp': datetime.utcnow().isoformat(),
'destination': ""
}
if result['requesturl'] in self._destinations:
payload['destination'] = self._destinations[result['requesturl']]
if result['requesturl'] in self._hostconfigs:
payload['destination'] = self._hostconfigs[result['requesturl']].get('dest_folder', "")
payload['remote_user'] = self._hostconfigs[result['requesturl']].get('remote_user', "")
payload['user_key'] = self._hostconfigs[result['requesturl']].get('user_key', "")
self._sensor_service.dispatch(trigger=trigger, payload=payload, trace_tag=runfolder_name)

def _load_config(self):
Expand Down

0 comments on commit 97f9b25

Please sign in to comment.