Add support for macro contexts that have colons (#51853)

Currently when used with macro contexts that have a colon inside, 
macro_name gets truncated. A common case is contexts that represent a 
Windows drive. Examples:

  - 'C_DRIVE_THRESHOLD: "C:"'
  - 'C_DRIVE_THRESHOLD: "D:"'

This happens because line 189 assumes there are only one colon in 
macro_name, and thus two substrings to join.

To solve this, it is necessary considering that macro_name could have 
more that one colon. After the split, the first element is the proper 
Zabbix macro name. Then, the solution is joining all the remaining 
substrings after that.

This is backwards compatible in the case macro_name have only one colon.
pull/52511/head
Pablo Piaggio 6 years ago committed by John R Barker
parent a1ec74334a
commit d1d4f4bd27

@ -186,7 +186,7 @@ def main():
force = module.params['force']
if ':' in macro_name:
macro_name = ':'.join([macro_name.split(':')[0].upper(), macro_name.split(':')[1]])
macro_name = ':'.join([macro_name.split(':')[0].upper(), ':'.join(macro_name.split(':')[1:])])
else:
macro_name = macro_name.upper()

Loading…
Cancel
Save