forked from levensailor/ciscoaxl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexamples.py
499 lines (323 loc) · 9.71 KB
/
examples.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
import os
from ciscoaxl import axl
from py_dotenv import read_dotenv
dotenv_path = os.path.join(os.path.dirname(__file__), '.env')
read_dotenv(dotenv_path)
cucm = os.getenv('cucm')
username = os.getenv('username')
password = os.getenv('password')
version = os.getenv('version')
print(cucm)
ucm = axl(username=username,password=password,cucm=cucm,cucm_version=version)
"""
Users
"""
print(ucm.get_users())
'''Get All Users'''
# for user in ucm.get_users():
# try:
# print(user)
# except Exception as e:
# print(e)
''''Get Specific User'''
# user = ucm.get_user(user_id='[email protected]')
# print(user)
''''Add User'''
# ucm.add_user(user_id='jlevensailor', last_name='Levensailor', first_name='Jeff')
''''Delete User'''
# ucm.delete_user(user_id='jlevensailor')
# ''''Update User'''
# ucm.update_user(user_id='jlevensailor', password='Lagavulin16', pin='5432')
"""
Phones
"""
#---Get Phones
# for phone in ucm.get_phones():
# print(phone.name)
#---Get Specific Phone
# phone = ucm.get_phone(name='SEP001122445566')
# print(phone.name)
#---Add Phone
# ucm.add_phone(
# name='SEP0023AF482340',
# description='Robert - 1102',
# product='Cisco 8861',
# device_pool='RTP_DP',
# location='RTP_LOC',
# phone_template='Standard 8861 SIP',
# protocol='SIP',
# css='AVST-CSS',
# subscribe_css='AVST-CSS',
# lines=[
# ('1102', 'ABQ_PT', 'Robert Smith', 'Robert Smith', 'Robert Smith - 1102', '+1408202XXXX')
# ]
# )
#---Delete Phone
# ucm.delete_phone('SEP004433220043')
"""
Translations and Transformations
"""
#---Get Translation Patterns
# for trans in ucm.get_translations():
# detailed = ucm.get_translation(uuid=trans.uuid)
# print(detailed.description)
#---Get Specific Translation Pattern
# trans = ucm.get_translation(pattern='2XXX', partition='xlates-pt')
# print(trans.description)
#---Add Translation Pattern
# ported = ['12324625544', '12324625545', '12324625546']
# for num in ported:
# ucm.add_translation(pattern=num, partition='pstn_pt',calledPartyTransformationMask='1102', callingSearchSpaceName='GW_CSS')
#---Delete Translation Pattern
# ucm.delete_translation(pattern='34567', partition='xlates-pt')
#---Update Translation Pattern
# ucm.update_translation(pattern='1234', partition='xlates-pt', newPattern='4567')
"""
Device Pools
"""
#---Get Device Pools
# for dp in ucm.get_device_pools():
# print(dp.name)
#---Get Specific Device Pool
# dp = ucm.get_device_pool(name='RTP_DP')
# print(dp.name)
#---Add Device Pool
# ucm.add_device_pool(device_pool='Hollywood_DP')
#---Delete Device Pool
# ucm.delete_device_pool(device_pool='Hollywood_DP')
#---Update Device Pool
# ucm.update_device_pool(name='RTP_DP', regionName='G711_RGN')
"""
CSS and Partitions
"""
#---Get Calling Search Spaces
# for css in ucm.get_calling_search_spaces():
# print(css.name)
#---Get Specific Calling Search Space
# css = ucm.get_calling_search_space(calling_search_space='pstn-css')
# print(css.name)
#---Add Calling Search Space
# ucm.add_calling_search_space(
# calling_search_space='VIP_CSS',
# description='Very Important Stuff'
# members=['losfeliz-pt','silverlake-pt','pstn-pt']
# )
#---Delete Calling Search Space
# ucm.update_calling_search_space(calling_search_space='VIP_CSS')
#---Delete Calling Search Space
# ucm.delete_calling_search_space(calling_search_space='VIP_CSS')
#---Get Partitions
# for pt in ucm.get_partitions():
# print(pt.name)
#---Get Specific Partition
# pt = ucm.get_partition(partition='pstn-pt')
# print(pt.name)
#---Add Partition
# sites = ['ABQ', 'PHX', 'FGS']
# for site in sites:
# ucm.add_partition(name=site+'_PT', description='Site Specific PT')
#---Delete Partition
# ucm.delete_partition(name='VIP_PT')
"""
Regions and Locations
"""
#---Get Regions
# for reg in ucm.get_regions():
# print(reg._uuid)
#---Get Specific Region
# reg = ucm.get_region(region='losfeliz_reg')
# print(reg.name)
#---Add Region
# ucm.add_region(region='Hollywood-REG')
#---Delete Region
# ucm.delete_region(region='Hollywood-REG')
#---Get Locations
# for loc in ucm.get_locations():
# print(loc.name)
#---Get Specific Location
# loc = ucm.get_location(name='Shadow')
# print(loc.name)
#---Add Location
# ucm.add_location(location='Hollywood-LOC')
#---Delete Location
# ucm.delete_location(location='Hollywood-LOC')
"""
Directory Numbers
"""
#---Get Directory Numbers
# for dn in ucm.get_directory_numbers():
# print(dn)
#---Get Specific Directory Number
# dn = ucm.get_directory_number(directory_number='2888',partition='losfeliz-pt')
# print(dn.uuid)
#---Add Directory Number
# ucm.add_directory_number(
# pattern='1102',
# partition='ABQ_PT'
# )
#---Delete Directory Number
# ucm.delete_directory_number(uuid='{0B0CDC93-EC9C-7255-1B09-40A3CE727D5A}')
"""
Device Profiles
"""
#---Get User Device Profiles
# for udp in ucm.get_device_profiles():
# print(udp.name)
#---Get Specific User Device Profile
# udp = ucm.get_device_profile(profile='udp-bsimpson')
# print(udp.name)
#---Add User Device Profile
# ucm.add_device_profile(
# profile='UDP_MScott',
# description='Michael Scott - 2901',
# product='Cisco 8861',
# phone_template='Standard 8861 SIP',
# protocol='SIP',
# lines=[
# ('2901', 'losfeliz-pt', 'Michael Scott', 'Michael Scott', 'Michael Scott - 2901', '+1408202XXXX'),
# ('2902', 'losfeliz-pt', 'Pam Beesley', 'Pam Beesley', 'Pam Beesley - 2902', '+1408202XXXX')
# ]
# )
#---Delete User Device Profile
# ucm.delete_device_profile('UDP_Mscott')
"""
CTI Route Points
"""
#---Get CTI Route Points
# for cti in ucm.get_cti_route_points():
# print(cti.name)
#---Get Specific CTI Route Point
# cti = ucm.get_cti_route_point(cti_route_point='AutoAttendant')
# print(cti.name)
#---Add CTI Route Point
# ucm.add_cti_route_point(
# cti_route_point='aa-pilot',
# description='pilot to unity',
# device_pool='LosFeliz_DP',
# css='allphone-css',
# lines=[
# ('2908', 'losfeliz-pt'),
# ('2909', 'losfeliz-pt')
# ]
# )
#---Delete CTI Route Point
# ucm.delete_cti_route_point(name='OneArch')
"""
CTI Route Points
"""
#---List Sip Trunks
# for trunk in ucm.get_sip_trunks():
# print(trunk.name)
#---Get Specific Sip Trunk
# trunk = ucm.get_sip_trunk(name='LosFeliz-Trunks')
# print(trunk.name)
#---Add a Sip Trunk
# trunk_info = {
# "name": "test-sip-trunk",
# "product": "SIP Trunk",
# "protocol": "SIP",
# "protocolSide": "Network",
# "description": "my new sip trunk",
# "callingSearchSpaceName": "WOB-HQ-GW-CSS",
# "devicePoolName": "WOB-HQ-DP",
# "securityProfileName": "Non Secure SIP Trunk Profile",
# "sipProfileName": "Standard SIP Profile",
# "runOnEveryNode": "t",
# "destinations": {"destination": {
# "addressIpv4": "4.1.2.3",
# "port": 5060,
# "sortOrder": "1"
# }}
# }
# this_add_siptrunk = ucm.add_sip_trunk(**trunk_info)
# print(this_add_siptrunk)
#---Update Sip Trunk
# ucm.update_sip_trunk(name='oldname', newName='newname')
#---Delete Sip Trunk
# ucm.delete_sip_trunk(name='atlanta')
"""
Route Groups, Lists, and Patterns
"""
#---List Route Plan
# nums = ['19197016707', '19197016712', '19197016713', '19197016706', '191970167016']
# for num in nums:
# for route in ucm.list_route_plan(num):
# print(route.dnOrPattern)
# for route in ucm.list_route_plan('2901'):
# print(route.uuid)
#---Get Route Groups
# for rg in ucm.get_route_groups():
# print(rg.name)
#--Get Specific Route Group
# rg = ucm.get_route_group(route_group='losfeliz-rg')
# print(rg.uuid)
#---Add Route Group
# ucm.add_route_group(
# route_group='hollywood-rg',
# distribution_algorithm='Circular',
# members=[('america-online-sip'), ('h323')])
#---Delete Route Group
# ucm.delete_route_group(route_group='hollywood-rg')
#---Get Route Lists
# for rl in ucm.get_route_lists():
# print(rl.name)
#---Get Specific Route List
# rl = ucm.get_route_list(route_list='stdloc-rl')
# print(rl.description)
#---Add Route List
# ucm.add_route_list(
# route_list='hollywood-rl',
# description='hollywood',
# run_on_all_nodes='true',
# cm_group_name='Default',
# members=[
# ('losfeliz-rg'),
# ('silverlake-rg')
# ])
#---Delete Route List
# ucm.delete_route_list(route_list='hollywood-rl')
#---Get Route Patterns
# for rp in ucm.get_route_patterns():
# print(rp.pattern)
#---Get Specific Route Pattern
# rp = ucm.get_route_pattern(pattern='911')
# print(rp.description)
#---Add Route Pattern
# ucm.add_route_pattern(
# pattern='999',
# partition='losfeliz-pt',
# description='Movie Times',
# route_list='stdloc-rl'
# )
#---Delete Route Pattern
# ucm.delete_route_pattern(pattern='999', partition='losfeliz-pt')
"""
Runs and Dos
"""
#---Execute SQL Query
# for sql in ucm.execute_sql_update(query):
# print(sql)
# def dothis(row):
# print(row)
# def build_query():
# with open("intercoms.txt") as intercoms:
# for row in intercoms:
# #print(row, end='')
# query = f'''
# UPDATE devicenumplanmap dnmp
# SET dnmp.speeddial = '', dnmp.label = 'ICM:'
# WHERE dnmp.speeddial = "{row[:10]}*"
# '''
# print(query)
# sql = ucm.execute_sql_update(query)
# print(sql)
# build_query()
#---Do LDAP Sync on all agreements
# for ldap in ucm.get_ldap_dir():
# ucm.do_ldap_sync(uuid=ldap.uuid)
#---Reset Device
# ucm.do_device_reset(device='SEP001100220033')
#---Extension Mobility Login
# ucm.do_device_login(device='SEP001100220033', userId='bsimpson')
#---Extension Mobility Logout
# ucm.do_device_logout(device='SEP001100220033', userId='bsimpson')