Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- from xivo_auth_client import Client as Auth
- from xivo_confd_client import Client as Confd
- # Please add a web service user with acl confd.#
- # To use ./change-sip-conf-params.py
- username = "sylvain" # Fill with your username
- password = "sylvain" # Fill with your password
- new_params = {'update':
- {
- 'videosupport': 'yes',
- 'nat': 'force_rport,comedia'
- },
- 'add': {},
- 'delete': {'toto': 'yes'}
- }
- ################ Do no modify ##############
- def get_token(username, password):
- token_data = auth.token.new('xivo_service', expiration=60)
- return token_data['token']
- auth = Auth('127.0.0.1', username=username, password=password, verify_certificate=False)
- token = get_token(username, password)
- confd = Confd('localhost', verify_certificate=False, token=token)
- options = confd.sip_general.list()['options']
- sip_general = {'options': []}
- for option in options:
- if option[0] in new_params['update']:
- opt = [option[0], new_params['update'][option[0]]]
- sip_general['options'].append(opt)
- elif option[0] in new_params['delete']:
- print "Removed: ", option
- else:
- sip_general['options'].append(option)
- for option in new_params['add']:
- sip_general['options'].append([option, new_params['add'][option]])
- confd.sip_general.update(sip_general)
- auth.token.revoke(token)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement