Merge pull request #7075 from beeankha/bye_bye_hipchat

Remove HipChat Notification Type

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
softwarefactory-project-zuul[bot] 2020-05-21 16:41:54 +00:00 committed by GitHub
commit 95a722255b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 47 additions and 166 deletions

View File

@ -2,6 +2,9 @@
This is a list of high-level changes for each release of AWX. A full list of commits can be found at `https://github.com/ansible/awx/releases/tag/<version>`.
## 12.0.0 (TBD)
- Removed support for HipChat notifications ([EoL announcement](https://www.atlassian.com/partnerships/slack/faq#faq-98b17ca3-247f-423b-9a78-70a91681eff0)); all previously-created HipChat notification templates will be deleted due to this removal.
## 11.2.0 (Apr 29, 2020)
- Inventory updates now use collection-based plugins by default (in Ansible 2.9+):
@ -103,7 +106,7 @@ This is a list of high-level changes for each release of AWX. A full list of com
- Updated the bundled version of openstacksdk to address a known issue https://github.com/ansible/awx/issues/5821
- Updated the bundled vmware_inventory plugin to the latest version to address a bug https://github.com/ansible/awx/pull/5668
- Fixed a bug that can cause inventory updates to fail to properly save their output when run within a workflow https://github.com/ansible/awx/pull/5666
- Removed a number of pre-computed fields from the Host and Group models to improve AWX performance. As part of this change, inventory group UIs throughout the interface no longer display status icons https://github.com/ansible/awx/pull/5448
- Removed a number of pre-computed fields from the Host and Group models to improve AWX performance. As part of this change, inventory group UIs throughout the interface no longer display status icons https://github.com/ansible/awx/pull/5448
## 9.1.1 (Jan 14, 2020)

View File

@ -0,0 +1,34 @@
# Generated by Django 2.2.11 on 2020-05-19 02:27
from django.db import migrations, models
def remove_hipchat_notifications(apps, schema_editor):
'''
HipChat notifications are no longer in service, remove any that are found.
'''
Notification = apps.get_model('main', 'Notification')
Notification.objects.filter(notification_type='hipchat').delete()
NotificationTemplate = apps.get_model('main', 'NotificationTemplate')
NotificationTemplate.objects.filter(notification_type='hipchat').delete()
class Migration(migrations.Migration):
dependencies = [
('main', '0115_v370_schedule_set_null'),
]
operations = [
migrations.RunPython(remove_hipchat_notifications),
migrations.AlterField(
model_name='notification',
name='notification_type',
field=models.CharField(choices=[('email', 'Email'), ('grafana', 'Grafana'), ('irc', 'IRC'), ('mattermost', 'Mattermost'), ('pagerduty', 'Pagerduty'), ('rocketchat', 'Rocket.Chat'), ('slack', 'Slack'), ('twilio', 'Twilio'), ('webhook', 'Webhook')], max_length=32),
),
migrations.AlterField(
model_name='notificationtemplate',
name='notification_type',
field=models.CharField(choices=[('email', 'Email'), ('grafana', 'Grafana'), ('irc', 'IRC'), ('mattermost', 'Mattermost'), ('pagerduty', 'Pagerduty'), ('rocketchat', 'Rocket.Chat'), ('slack', 'Slack'), ('twilio', 'Twilio'), ('webhook', 'Webhook')], max_length=32),
),
]

View File

@ -23,7 +23,6 @@ from awx.main.notifications.email_backend import CustomEmailBackend
from awx.main.notifications.slack_backend import SlackBackend
from awx.main.notifications.twilio_backend import TwilioBackend
from awx.main.notifications.pagerduty_backend import PagerDutyBackend
from awx.main.notifications.hipchat_backend import HipChatBackend
from awx.main.notifications.webhook_backend import WebhookBackend
from awx.main.notifications.mattermost_backend import MattermostBackend
from awx.main.notifications.grafana_backend import GrafanaBackend
@ -44,7 +43,6 @@ class NotificationTemplate(CommonModelNameNotUnique):
('twilio', _('Twilio'), TwilioBackend),
('pagerduty', _('Pagerduty'), PagerDutyBackend),
('grafana', _('Grafana'), GrafanaBackend),
('hipchat', _('HipChat'), HipChatBackend),
('webhook', _('Webhook'), WebhookBackend),
('mattermost', _('Mattermost'), MattermostBackend),
('rocketchat', _('Rocket.Chat'), RocketChatBackend),

View File

@ -1,54 +0,0 @@
# Copyright (c) 2016 Ansible, Inc.
# All Rights Reserved.
import logging
import requests
from django.utils.encoding import smart_text
from django.utils.translation import ugettext_lazy as _
from awx.main.notifications.base import AWXBaseEmailBackend
from awx.main.notifications.custom_notification_base import CustomNotificationBase
logger = logging.getLogger('awx.main.notifications.hipchat_backend')
class HipChatBackend(AWXBaseEmailBackend, CustomNotificationBase):
init_parameters = {"token": {"label": "Token", "type": "password"},
"rooms": {"label": "Destination Rooms", "type": "list"},
"color": {"label": "Notification Color", "type": "string"},
"api_url": {"label": "API Url (e.g: https://mycompany.hipchat.com)", "type": "string"},
"notify": {"label": "Notify room", "type": "bool"},
"message_from": {"label": "Label to be shown with notification", "type": "string"}}
recipient_parameter = "rooms"
sender_parameter = "message_from"
def __init__(self, token, color, api_url, notify, fail_silently=False, **kwargs):
super(HipChatBackend, self).__init__(fail_silently=fail_silently)
self.token = token
if color is not None:
self.color = color.lower()
self.api_url = api_url
self.notify = notify
def send_messages(self, messages):
sent_messages = 0
for m in messages:
for rcp in m.recipients():
r = requests.post("{}/v2/room/{}/notification".format(self.api_url, rcp),
params={"auth_token": self.token},
verify=False,
json={"color": self.color,
"message": m.subject,
"notify": self.notify,
"from": m.from_email,
"message_format": "text"})
if r.status_code != 204:
logger.error(smart_text(_("Error sending messages: {}").format(r.text)))
if not self.fail_silently:
raise Exception(smart_text(_("Error sending message to hipchat: {}").format(r.text)))
sent_messages += 1
return sent_messages

View File

@ -168,22 +168,6 @@ export default ['i18n', function(i18n) {
subForm: 'typeSubForm',
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)'
},
rooms: {
label: i18n._('Destination Channels'),
type: 'textarea',
rows: 3,
awPopOver: i18n._('Enter one HipChat channel per line. The pound symbol (#) is not required.'),
dataTitle: i18n._('Destination Channels'),
dataPlacement: 'right',
dataContainer: "body",
awRequiredWhen: {
reqExpression: "room_required",
init: "false"
},
ngShow: "notification_type.value == 'hipchat'",
subForm: 'typeSubForm',
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)'
},
token: {
labelBind: 'tokenLabel',
type: 'sensitive',
@ -344,18 +328,6 @@ export default ['i18n', function(i18n) {
subForm: 'typeSubForm',
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)'
},
api_url: {
label: i18n._('API URL'),
type: 'text',
placeholder: 'https://mycompany.hipchat.com',
awRequiredWhen: {
reqExpression: "hipchat_required",
init: "false"
},
ngShow: "notification_type.value == 'hipchat' ",
subForm: 'typeSubForm',
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)'
},
message_from: {
label: i18n._('Notification Label'),
type: 'text',

View File

@ -81,6 +81,7 @@ The following notes are changes that may require changes to playbooks:
- `tower_job_template` no longer supports the deprecated `extra_vars_path` parameter, please use `extra_vars` with the lookup plugin to replace this functionality.
- The `notification_configuration` parameter of `tower_notification` has changed from a string to a dict. Please use the `lookup` plugin to read an existing file into a dict.
- `tower_credential` no longer supports passing a file name to ssh_key_data.
- The HipChat `notification_type` has been removed and can no longer be created using the `tower_notification` module.
## Running Unit Tests

View File

@ -46,7 +46,6 @@ options:
choices:
- 'email'
- 'grafana'
- 'hipchat'
- 'irc'
- 'mattermost'
- 'pagerduty'
@ -156,23 +155,12 @@ options:
- The label to be shown with the notification.
- This parameter has been deprecated, please use 'notification_configuration' instead.
type: str
api_url:
description:
- The HipChat API URL.
- This parameter has been deprecated, please use 'notification_configuration' instead.
type: str
color:
description:
- The notification color.
- This parameter has been deprecated, please use 'notification_configuration' instead.
choices: ["yellow", "green", "red", "purple", "gray", "random"]
type: str
rooms:
description:
- HipChat rooms to send the notification to.
- This parameter has been deprecated, please use 'notification_configuration' instead.
type: list
elements: str
notify:
description:
- The notify channel trigger.
@ -293,21 +281,6 @@ EXAMPLES = '''
state: present
tower_config_file: "~/tower_cli.cfg"
- name: Add HipChat notification
tower_notification:
name: hipchat notification
notification_type: hipchat
notification_configuration:
token: a_token
message_from: user1
api_url: https://hipchat.example.com
color: red
rooms:
- room-A
notify: yes
state: present
tower_config_file: "~/tower_cli.cfg"
- name: Add IRC notification
tower_notification:
name: irc notification
@ -341,8 +314,8 @@ OLD_INPUT_NAMES = (
'host', 'use_ssl', 'password', 'port',
'channels', 'token', 'account_token', 'from_number',
'to_numbers', 'account_sid', 'subdomain', 'service_key',
'client_name', 'message_from', 'api_url', 'color',
'rooms', 'notify', 'url', 'headers', 'server',
'client_name', 'message_from', 'color',
'notify', 'url', 'headers', 'server',
'nickname', 'targets',
)
@ -355,7 +328,7 @@ def main():
description=dict(),
organization=dict(),
notification_type=dict(choices=[
'email', 'grafana', 'hipchat', 'irc', 'mattermost',
'email', 'grafana', 'irc', 'mattermost',
'pagerduty', 'rocketchat', 'slack', 'twilio', 'webhook'
]),
notification_configuration=dict(type='dict'),
@ -378,9 +351,7 @@ def main():
service_key=dict(no_log=True),
client_name=dict(),
message_from=dict(),
api_url=dict(),
color=dict(choices=['yellow', 'green', 'red', 'purple', 'gray', 'random']),
rooms=dict(type='list', elements='str'),
notify=dict(type='bool'),
url=dict(),
headers=dict(type='dict'),
@ -395,7 +366,7 @@ def main():
# Extract our parameters
name = module.params.get('name')
new_name = module.params.get("new_name")
new_name = module.params.get('new_name')
description = module.params.get('description')
organization = module.params.get('organization')
notification_type = module.params.get('notification_type')
@ -403,10 +374,10 @@ def main():
messages = module.params.get('messages')
state = module.params.get('state')
# Deprecation warnings
# Deprecation warnings for all other params
for legacy_input in OLD_INPUT_NAMES:
if module.params.get(legacy_input) is not None:
module.deprecate(msg='{0} parameter has been deprecated, please use notification_configuration instead.'.format(legacy_input), version="3.6")
module.deprecate(msg='{0} parameter has been deprecated, please use notification_configuration instead'.format(legacy_input), version="3.6")
# Attempt to look up the related items the user specified (these will fail the module if not found)
organization_id = None

View File

@ -6,7 +6,6 @@
email_not: "AWX-Collection-tests-tower_notification-email-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
twillo_not: "AWX-Collection-tests-tower_notification-twillo-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
pd_not: "AWX-Collection-tests-tower_notification-pd-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
hipchat_not: "AWX-Collection-tests-tower_notification-hipchat-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
irc_not: "AWX-Collection-tests-tower_notification-irc-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
- name: Test deprecation warnings
@ -35,19 +34,7 @@
service_key: skeleton
client_name: Bill
message_from: me
api_url: https://tower.example.com/api/v2
color: green
rooms:
- The Study
- Kitchen
- Ballroom
- Conservatory
- Billiard Room
- Library
- Hall
- Lounge
- Dining Room
- Cellar
notify: true
url: ansible.com
headers:
@ -63,8 +50,8 @@
- assert:
that:
- "'deprecations' in result"
# The 27 can be count from the size of the OLD_INPUT_NAMES list in the module
- result['deprecations'] | length() == 27
# The 25 can be count from the size of the OLD_INPUT_NAMES list in the module
- result['deprecations'] | length() == 25
- name: Create Slack notification with custom messages
tower_notification:
@ -212,36 +199,6 @@
that:
- result is changed
- name: Add HipChat notification
tower_notification:
name: "{{ hipchat_not }}"
organization: Default
notification_type: hipchat
token: a_token
message_from: user1
api_url: https://hipchat.example.com
color: red
rooms:
- room-A
notify: true
state: present
register: result
- assert:
that:
- result is changed
- name: Delete HipChat notification
tower_notification:
name: "{{ hipchat_not }}"
organization: Default
state: absent
register: result
- assert:
that:
- result is changed
- name: Add IRC notification
tower_notification:
name: "{{ irc_not }}"

View File

@ -72,7 +72,6 @@ The currently-defined Notification Types are:
* Email
* Slack
* HipChat
* Mattermost
* Rocket.Chat
* Pagerduty