Skip to content

Commit

Permalink
fix zabbix_action module for zabbix6 - discovery action (#653)
Browse files Browse the repository at this point in the history
  • Loading branch information
crashwind authored Mar 21, 2022
1 parent e16519e commit 4af4d3f
Showing 1 changed file with 19 additions and 2 deletions.
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

0 comments on commit 4af4d3f

Please sign in to comment.