-
Notifications
You must be signed in to change notification settings - Fork 1
/
cucm_helper.py
43 lines (32 loc) · 1.23 KB
/
cucm_helper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""
CUCM Call Routing Editor - A simple call routing editor for Cisco CUCM
Copyright (C) 2020 Billy Zoellers, Dean Dorton Allen Ford, PLLC
cucm_helper.py / Helper functions for CUCM AXL API operations
"""
from ciscoaxl import axl
from zeep.exceptions import Fault
def get_ucm(user, password, host, version):
ucm = axl(username=user,password=password,cucm=host,cucm_version=version)
return ucm
def get_translation_patterns_with_uuids(ucm, uuids):
patterns = []
for uuid in uuids:
pattern = ucm.get_translation(uuid=uuid)
if isinstance(pattern, Fault):
raise Exception(pattern)
patterns.append(pattern["return"]["transPattern"])
return patterns
def update_translation_pattern_called_party_mask(ucm, uuid, mask):
pattern = get_translation_patterns_with_uuids(ucm=ucm, uuids=[uuid])[0]
current_mask = pattern['calledPartyTransformationMask']
response = {
"uuid": uuid.lower(),
"oldmask": current_mask,
"newmask": current_mask,
}
if pattern['calledPartyTransformationMask'] != mask:
update_mask = ucm.update_translation(uuid=uuid, calledPartyTransformationMask=mask)
if isinstance(update_mask, Fault):
raise Exception(update_mask)
response['newmask'] = mask
return response