-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path01 AXL Introduction.py
98 lines (80 loc) · 3.07 KB
/
01 AXL Introduction.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import requests
import xmltodict
import json
import urllib3
from lxml import etree, objectify
import env.user_env
UCM_PUBLISHER = env.user_env.CUCM_IP
AXL_USER = env.user_env.CUCM_ADMIN_USER
AXL_PASSWORD = env.user_env.CUCM_ADMIN_PASSWORD
# from connection_parameters import *
def axl_test():
# disable warnings for HTTPS sessions w/ diabled cert validation
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
axl_endpoint = f'https://{UCM_PUBLISHER}:8443/axl'
print(f'Accessing {axl_endpoint}')
r = requests.get(axl_endpoint, auth=(AXL_USER, AXL_PASSWORD), verify=False)
r.raise_for_status()
print(r.text)
def get_version():
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
axl_endpoint = f'https://{UCM_PUBLISHER}:8443/axl/'
body = """
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.cisco.com/AXL/API/11.0">
<soapenv:Header/>
<soapenv:Body>
<ns:getCCMVersion>
</ns:getCCMVersion>
</soapenv:Body>
</soapenv:Envelope>"""
headers = {
'SOAPAction': 'CUCM:DB ver=11.0 getCCMVersion',
'Content-Type': 'text/xml;charset=UTF-8'
}
r = requests.post(axl_endpoint, auth=(AXL_USER, AXL_PASSWORD), verify=False, data=body, headers=headers)
print(r.text)
element_tree = etree.fromstring(r.text.encode())
print(element_tree)
print(etree.tostring(element_tree, pretty_print=True).decode())
version:etree._Element = element_tree.find('.//version')
print(f'Version: {version.text}')
def list_css():
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
axl_endpoint = f'https://{UCM_PUBLISHER}:8443/axl/'
body = """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns="http://www.cisco.com/AXL/API/11.0">
<soapenv:Header/>
<soapenv:Body>
<ns:listCss >
<searchCriteria>
<name>%</name>
</searchCriteria>
<returnedTags uuid="?">
<description>?</description>
<clause>?</clause>
<dialPlanWizardGenId>?</dialPlanWizardGenId>
<partitionUsage>?</partitionUsage>
<name>?</name>
</returnedTags>
<first>10</first>
</ns:listCss>
</soapenv:Body>
</soapenv:Envelope>"""
headers = {
'SOAPAction': 'CUCM:DB ver=11.0 listCss',
'Content-Type': 'text/xml;charset=UTF-8'
}
r = requests.post(axl_endpoint, auth=(AXL_USER, AXL_PASSWORD), verify=False, data=body, headers=headers)
r.raise_for_status()
element_tree = etree.fromstring(r.text.encode())
print(etree.tostring(element_tree, pretty_print=True).decode())
axl_return = element_tree.find('.//return')
css_list = []
for css_element in axl_return:
css = {e.tag:e.text for e in css_element}
css_list.append(css)
print(css_list)
if __name__ == '__main__':
axl_test()
get_version()
list_css()