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

fix zabbix_action module for zabbix6 - discovery action #653

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions plugins/modules/zabbix_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,17 @@ def _construct_parameters(self, **kwargs):
_params['update_operations'] = []
_params.pop('acknowledge_operations', None)

if 'esc_period' in _params and isinstance(_params.get('esc_period', None), type(None)):
_params.pop('esc_period')

if 'recovery_operations' in _params:
if isinstance(_params.get('recovery_operations', None), type(None)) or len(_params.get('recovery_operations', [])) == 0:
_params.pop('recovery_operations')

if 'update_operations' in _params:
if isinstance(_params.get('update_operations', None), type(None)) or len(_params.get('update_operations', [])) == 0:
_params.pop('update_operations')

return _params

def check_difference(self, **kwargs):
Expand Down Expand Up @@ -1183,7 +1194,9 @@ def construct_the_data(self, operations):
constructed_operation['opmessage'] = self._construct_opmessage(op)
constructed_operation['opmessage_usr'] = self._construct_opmessage_usr(op)
constructed_operation['opmessage_grp'] = self._construct_opmessage_grp(op)
constructed_operation['opconditions'] = self._construct_opconditions(op)

if LooseVersion(self._zbx_api_version) < LooseVersion('6.0'):
constructed_operation['opconditions'] = self._construct_opconditions(op)

# Send Command type
if constructed_operation['operationtype'] == '1':
Expand All @@ -1204,6 +1217,11 @@ def construct_the_data(self, operations):
if constructed_operation['operationtype'] == '10':
constructed_operation['opinventory'] = self._construct_opinventory(op)

# Remove escalation params when escalation period is None (null)
if isinstance(constructed_operation.get('esc_period'), type(None)):
constructed_operation.pop('esc_step_from')
constructed_operation.pop('esc_step_to')

constructed_data.append(constructed_operation)

return cleanup_data(constructed_data)
Expand Down Expand Up @@ -1981,7 +1999,6 @@ def main():
argument_spec=argument_spec,
required_if=[
['state', 'present', [
'esc_period',
'event_source'
]]
],
Expand Down