Browse Source

handle being passed an empty group list

Previous version would have the behavior where when an empty list is passed, the zbx API call would return a list of all groups. So an action with no groups defined would default to having all groups added to the operations.
Handle this by iterating one at a time through the list of provided groups. When an empty list is provided, and empty list is returned.
Joel Diaz 9 years ago
parent
commit
77517fcaea
1 changed files with 6 additions and 6 deletions
  1. 6 6
      roles/lib_zabbix/library/zbx_action.py

+ 6 - 6
roles/lib_zabbix/library/zbx_action.py

@@ -228,12 +228,12 @@ def get_user_groups(zapi, groups):
     '''get the mediatype id from the mediatype name'''
     '''get the mediatype id from the mediatype name'''
     user_groups = []
     user_groups = []
 
 
-    content = zapi.get_content('usergroup',
+    for group in groups:
-                               'get',
+        content = zapi.get_content('usergroup',
-                               {'search': {'name': groups}})
+                                   'get',
-
+                                   {'search': {'name': group}})
-    for usr_grp in content['result']:
+        for result in content['result']:
-        user_groups.append({'usrgrpid': usr_grp['usrgrpid']})
+            user_groups.append({'usrgrpid': result['usrgrpid']})
 
 
     return user_groups
     return user_groups