diff --git a/adjutant/notifications/request_tracker/__init__.py b/adjutant/notifications/request_tracker/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/adjutant/notifications/request_tracker/migrations/__init__.py b/adjutant/notifications/request_tracker/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/adjutant/notifications/request_tracker/models.py b/adjutant/notifications/request_tracker/models.py deleted file mode 100644 index fccf94f..0000000 --- a/adjutant/notifications/request_tracker/models.py +++ /dev/null @@ -1,100 +0,0 @@ -# Copyright (C) 2015 Catalyst IT Ltd -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from django.conf import settings -from django.template import loader -from adjutant.notifications.models import NotificationEngine -from adjutant.api.models import Notification -from rtkit.resource import RTResource -from rtkit.authenticators import CookieAuthenticator -from rtkit.errors import RTResourceError - - -class RTNotification(NotificationEngine): - """ - Request Tracker notification engine. Will - create a new ticket in RT for the notification. - - Example conf: - : - notifications: - standard: - RTNotification: - url: http://localhost/rt/REST/1.0/ - queue: helpdesk - username: example@example.com - password: password - template: notification.txt - error: - RTNotification: - url: http://localhost/rt/REST/1.0/ - queue: errors - username: example@example.com - password: password - template: notification.txt - : - ... - """ - - def __init__(self, conf): - super(RTNotification, self).__init__(conf) - tracker = RTResource( - self.conf['url'], self.conf['username'], self.conf['password'], - CookieAuthenticator) - self.tracker = tracker - - def _notify(self, task, notification): - template = loader.get_template(self.conf['template']) - - context = {'task': task, 'notification': notification} - - message = template.render(context) - - if notification.error: - subject = "Error - %s notification" % task.task_type - else: - subject = "%s notification" % task.task_type - - content = { - 'content': { - 'Queue': self.conf['queue'], - 'Subject': subject, - 'Text': message, - } - } - - try: - self.tracker.post(path='ticket/new', payload=content) - if not notification.error: - notification.acknowledged = True - notification.save() - except RTResourceError as e: - notes = { - 'errors': - [("Error: '%s' while sending notification to " + - "RT.") % e] - } - error_notification = Notification.objects.create( - task=notification.task, - notes=notes, - error=True - ) - error_notification.save() - - -notification_engines = { - 'RTNotification': RTNotification, -} - -settings.NOTIFICATION_ENGINES.update(notification_engines) diff --git a/conf/conf.yaml b/conf/conf.yaml index aa9dbb3..a5921a4 100644 --- a/conf/conf.yaml +++ b/conf/conf.yaml @@ -9,7 +9,6 @@ ALLOWED_HOSTS: ADDITIONAL_APPS: - adjutant.api.v1 - adjutant.actions.v1 - - adjutant.notifications.request_tracker DATABASES: default: @@ -110,19 +109,6 @@ DEFAULT_TASK_SETTINGS: from: bounce+%(task_uuid)s@example.com template: notification.txt # html_template: completed.txt - RTNotification: - standard: - url: http://localhost/rt/REST/1.0/ - queue: helpdesk - username: example@example.com - password: password - template: notification.txt - error: - url: http://localhost/rt/REST/1.0/ - queue: errors - username: example@example.com - password: password - template: notification.txt # Default Action settings: # These can be overriden at a per task level below in the @@ -248,11 +234,6 @@ TASK_SETTINGS: error: emails: - signups@example.com - RTNotification: - standard: - queue: signups - error: - queue: signups default_region: RegionOne # If 'None' (null in yaml), will default to domain as parent. # If domain isn't set explicity, will service user domain (see KEYSTONE). diff --git a/requirements.txt b/requirements.txt index 6447b4a..f29e2ae 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,5 +15,4 @@ six>=1.10.0 jsonfield>=2.0.1 django-rest-swagger>=2.1.2 pyyaml>=3.12 -python-rtkit>=0.7.1 mysqlclient>=1.3.10