From f7c91d08a004561cac95c674defc7ffd7812cee9 Mon Sep 17 00:00:00 2001 From: jurgenhaas <juergen@paragon-es.de> Date: Thu, 7 Apr 2016 09:05:36 +0200 Subject: [PATCH] ansible-plugins/uptime#1 Include tracker source and included projects into unique keys for checks --- action_plugins/uptime.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/action_plugins/uptime.py b/action_plugins/uptime.py index 17dc8fc..33b4bec 100644 --- a/action_plugins/uptime.py +++ b/action_plugins/uptime.py @@ -189,9 +189,10 @@ class ActionModule(ActionBase): self._request('checks/' + existing.get('_id'), existing, 'POST') - def _findExistingCheck(self, url, type): + def _findExistingCheck(self, url, type, tracker_source, tracker_project_include): for check in self.checks: - if (check.get('url') == url and check.get('type') == type): + pollerParams = check.get('pollerParams', []) + if (check.get('url') == url and check.get('type') == type and pollerParams.get('tracker_source', '') == tracker_source and pollerParams.get('tracker_project_include', '') == tracker_project_include): return check return False @@ -284,7 +285,9 @@ class ActionModule(ActionBase): def _processItem(self, host_vars, item, field): url = self._buildUrl(item, field) check = self._buildCheck(host_vars, item, url) - existing = self._findExistingCheck(url, check['type']) + tracker_source = check.get('tracker_source', '') + tracker_project_include = check.get('tracker_project_include', '') + existing = self._findExistingCheck(url, check['type'], tracker_source, tracker_project_include) if existing: if check['enabled']: self._updateCheck(existing, check) -- GitLab