Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing mediatype default value #53114

Merged
merged 2 commits into from
Mar 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/ansible/modules/monitoring/zabbix/zabbix_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@
media_type:
description:
- Media type that will be used to send the message.
- Set to C(all) for all media types
default: 'all'
host_groups:
type: list
description:
Expand Down Expand Up @@ -664,6 +666,8 @@ def get_mediatype_by_mediatype_name(self, mediatype_name):

"""
try:
if str(mediatype_name).lower() == 'all':
return '0'
mediatype_list = self._zapi.mediatype.get({
'output': 'extend',
'selectInventory': 'extend',
Expand All @@ -672,7 +676,7 @@ def get_mediatype_by_mediatype_name(self, mediatype_name):
if len(mediatype_list) < 1:
self._module.fail_json(msg="Media type not found: %s" % mediatype_name)
else:
return mediatype_list[0]
return mediatype_list[0]['mediatypeid']
except Exception as e:
self._module.fail_json(msg="Failed to get mediatype '%s': %s" % (mediatype_name, e))

Expand Down Expand Up @@ -913,7 +917,7 @@ def _construct_opmessage(self, operation):
'default_msg': '0' if 'message' in operation or 'subject' in operation else '1',
'mediatypeid': self._zapi_wrapper.get_mediatype_by_mediatype_name(
operation.get('media_type')
)['mediatypeid'] if operation.get('media_type') is not None else None,
) if operation.get('media_type') is not None else '0',
'message': operation.get('message'),
'subject': operation.get('subject'),
}
Expand Down