-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path09_addPhone.py
71 lines (64 loc) · 2.18 KB
/
09_addPhone.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
from requests import Session
from zeep import Client
from zeep.transports import Transport
from urllib3 import disable_warnings
from urllib3.exceptions import InsecureRequestWarning
from zeep.cache import SqliteCache
from zeep.plugins import HistoryPlugin
from zeep.exceptions import Fault
from zeep.helpers import serialize_object
from lxml import etree
from requests.auth import HTTPBasicAuth
disable_warnings(InsecureRequestWarning)
username = 'axluser'
password = '1Qaz2Wsx'
fqdn = '192.168.80.100'
address = 'https://{}:8443/axl/'.format(fqdn)
wsdl = 'AXLAPI.wsdl'
binding = "{http://www.cisco.com/AXLAPIService/}AXLAPIBinding"
session = Session()
session.verify = False
session.auth = HTTPBasicAuth(username, password)
transport = Transport(cache=SqliteCache(), session=session, timeout=20)
history = HistoryPlugin()
client = Client(wsdl=wsdl, transport=transport, plugins=[history])
axl = client.create_service(binding, address)
def show_history():
for item in [history.last_sent, history.last_received]:
print(etree.tostring(item["envelope"], encoding="unicode", pretty_print=True))
try:
userid = 'imansur'
addPhoneinfo = axl.addPhone(phone = {
'name' : f'CSF{userid}',
'product' : 'Cisco Unified Client Services Framework',
'class' : 'Phone',
'protocol' : 'SIP',
'protocolSide' : 'User',
'devicePoolName' : 'Default',
'commonPhoneConfigName': 'Standard Common Phone Profile',
'locationName' : 'Hub_None',
'useTrustedRelayPoint' : 'Default',
'ownerUserName' : 'imansur',
'phoneTemplateName' : 'Standard Client Services Framework',
'lines' : {
'line' : [{
'label' : 'dirn 1000',
'index' : '1',
'dirn' : {
'pattern' : '1000',
'routePartitionName' : 'PT_A'
}
},
{
'label' : 'dirn 1001',
'index' : '2' ,
'dirn' : {
'pattern' : '1001',
'routePartitionName' : 'PT_B'
}
}]
}
}
)
except Fault as f:
print (f)