Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. from xivo_auth_client import Client as Auth
  4. from xivo_confd_client import Client as Confd
  5.  
  6.  
  7. # Please add a web service user with acl confd.#
  8. # To use ./change-sip-conf-params.py
  9.  
  10. username = "sylvain" # Fill with your username
  11. password = "sylvain" # Fill with your password
  12.  
  13. new_params = {'update':
  14. {
  15. 'videosupport': 'yes',
  16. 'nat': 'force_rport,comedia'
  17. },
  18. 'add': {},
  19. 'delete': {'toto': 'yes'}
  20. }
  21.  
  22. ################ Do no modify ##############
  23.  
  24. def get_token(username, password):
  25. token_data = auth.token.new('xivo_service', expiration=60)
  26. return token_data['token']
  27.  
  28. auth = Auth('127.0.0.1', username=username, password=password, verify_certificate=False)
  29. token = get_token(username, password)
  30. confd = Confd('localhost', verify_certificate=False, token=token)
  31.  
  32. options = confd.sip_general.list()['options']
  33.  
  34. sip_general = {'options': []}
  35.  
  36. for option in options:
  37. if option[0] in new_params['update']:
  38. opt = [option[0], new_params['update'][option[0]]]
  39. sip_general['options'].append(opt)
  40. elif option[0] in new_params['delete']:
  41. print "Removed: ", option
  42. else:
  43. sip_general['options'].append(option)
  44.  
  45. for option in new_params['add']:
  46. sip_general['options'].append([option, new_params['add'][option]])
  47.  
  48. confd.sip_general.update(sip_general)
  49.  
  50. auth.token.revoke(token)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement