Cisco CUCM AXL Python3 & Suds – Bulk Insert Speed Dials

By 24th October 2017AXL, Cisco, CUCM

I wrote the following script for a client who were migrating to CUCM from another platform and had a requirement to transfer across 1000’s of speed dials from the old PBX to the new Users Device Profiles. The same task would take you a very long time to update the entries manually or via a bulk device update.

The application requires an input file with the following values:
Device = Device name, in this case the UDP name.
Position = The position of the speed dial, not necessarily the button on which it will reside.
Number = The actual speed dial number to be used.
Label = The label which will appear on newer devices.
Acsii = The label which will apear on older devices.

Input File
 
  1. Device,Position,Number,Label,Ascii
  2. UDP_8205702_8861,3,902074148861,Mitch,Mitch
Full Code
 
  1. __author__ = "Mitch Dawson"
  2. __contact__ = "info@ucdevops.com"
  3. __copyright__ = "Copyright (C) 2017 - 2021 Ucdevops All Rights Reserved"
  4. __license__ = "GPLv3"
  5. """
  6. This program is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program. If not, see http://www.gnu.org/licenses.
  16. """
  17. # Define Authentication Credentials for the cluster
  18. u = 'username'
  19. p = 'password'
  20. # Define AXL URL for the cluster
  21. url = 'https://CUCM:8443/axl/'
  22. # Define WSDL Locations
  23. wsdl1 = 'file:///C:/PathTo/AXLAPI.wsdl'
  24. # Create the Suds client Object
  25. client = Client(
  26.     location=url, url=wsdl1,
  27.     username=u, password=p,
  28.     cache=NoCache()
  29. )
  30. # Define the SQL Query
  31. query = """
  32. INSERT INTO speeddial
  33. (fkdevice, speeddialindex, speeddialnumber, label, labelascii)
  34. VALUES (
  35. (SELECT pkid from device where name = "{0}"),
  36. "{1}", "{2}", "{3}", "{4}"
  37. )
  38. """
  39. # Open input file then read it then split on new line
  40. file = open('speeddial.txt', 'r').read().split('\n')
  41. # Loop Through the file skipping the header line
  42. for line in file[1:]:
  43.     # Break out the Components from the text file
  44.     dev, pos, num, lab, asc = line.split(',')
  45.     # Format the SQL query with the values we require
  46.     query = query.format(dev, pos, num, lab, asc)
  47.     # Make the API call
  48.     resp = client.service.executeSQLUpdate(query)
  49.     print(resp)
Successful Response
 
  1. (reply){
  2.    return =
  3.       (return){
  4.          rowsUpdated = 1
  5.       }
  6.  }
Mitch

Author Mitch

I am an independent IT Consultant with specialities in Software Development, Enterprise Unified Communication, Network and Security platforms. In addition to my day to day work, I develop bespoke applications and I hope that through ucdevops.com I can build relationships with clients, business partners and fellow engineers by providing solutions to complex problems through the use of programming.

More posts by Mitch

Leave a Reply

"