Skip to content

Commit

Permalink
Upgrade command create_notification_user
Browse files Browse the repository at this point in the history
- Add remarks parameter. Better with a comment to have information
  about the telefon used when creating a SMS notification user.
  • Loading branch information
rafaelma committed Mar 30, 2016
1 parent 2508bcc commit 7e685aa
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions zabbix_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2969,7 +2969,7 @@ def do_create_notification_user(self,args):
COMMAND:
create_notification_user [sendto]
[mediatype]
[remarks]
[sendto]
--------
E-mail address or SMS number
Expand All @@ -2979,6 +2979,11 @@ def do_create_notification_user(self,args):
One of the media types names defined in your Zabbix
installation, e.g. Email, SMS
[remarks]
---------
Comments about this user. e.g. Johns cellphone.
Max lenght is 20 characters.
'''

# Default: md5 value of a random int >1 and <1000000
Expand Down Expand Up @@ -3016,6 +3021,7 @@ def do_create_notification_user(self,args):
print '--------------------------------------------------------'
sendto = raw_input('# SendTo []: ').strip()
mediatype = raw_input('# Media type []: ').strip()
remarks = raw_input('# Remarks []: ').strip()
print '--------------------------------------------------------'

except Exception as e:
Expand All @@ -3027,10 +3033,11 @@ def do_create_notification_user(self,args):
# Command with parameters
#

elif len(arg_list) == 2:
elif len(arg_list) == 3:

sendto = arg_list[0].strip()
mediatype = arg_list[1].strip()
remarks = arg_list[2].strip()

#
# Command with the wrong number of parameters
Expand All @@ -3052,7 +3059,11 @@ def do_create_notification_user(self,args):
self.generate_feedback('Error','Media type is empty')
return False

alias = 'notification-user-' + sendto.replace('.','-')
if remarks.strip() == '':
alias = 'notification-user-' + sendto.replace('.','-')
else:
alias = 'notification-user-' + remarks.strip()[:20].replace(' ','_') + '-' + sendto.replace('.','-')

passwd = passwd_default
type = type_default
autologin = autologin_default
Expand Down

0 comments on commit 7e685aa

Please sign in to comment.