Cisco CUCM AXL Python3 – Remote Login

By 12th December 2016AXL, Cisco, CUCM

I thought I would share a the following script which comes in very handy when you need to log users into Cisco handsets on CUCM remotely.
The script reads a standard csv input file with the following fields – dn,pn,uid (these arent important, but serve to outline which values you need provide and the order that they are passed to the application). This example uses the “Suds Jurko” soap library to ingest and parse the CUCM WSDL file in order to dynamically create the required XML message(s), however you can make a raw xml post to the api if you format the message correctly. Please see some of our other posts for XML formatting examples. This example uses the AXL API method “doDeviceLogin”, you can find an example using standard Extension Mobility API here.

mac = MAC Address
profile = UDP Name
uid = User Id

Input File
  1. mac,profile,uid
  2. SEP002414B36E25,UDP_8205702_7965,Mitch.Dawson
Full Code
  1. __author__ = "Mitch Dawson"
  2. __contact__ = ""
  3. __copyright__ = "Copyright (C) 2017 - 2018 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
  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
  16. """
  17. from suds.client import Client  
  19. # Define AXL Authentication Credentials for Cluster  
  20. username = "username"  
  21. password = "password"  
  23. # Define AXL URL for Cluster  
  24. url = "https://CUCM:8443/axl/"  
  26. # Define WSDL Location 
  27. wsdl = "file:///C:/pathto/AXLAPI.wsdl"  
  29. # Build SUDS Client Connection  
  30. client = Client(location=url, url=wsdl, retxml=False, username=username, password=password)
  31. # Open and read csv File, split on new line
  32. data = open("login.csv", "r").read().split("\n")
  34. # loop through and break out individual components  
  35. for line in data[1:]:  
  36.   mac,profile,uid = line.split(",") 
  37.   print(mac,profile,uid)
  39.   # Call client service "doDeviceLogin" method and pass in the parameters  
  40.   x = client.service.doDeviceLogin(deviceName=dn, loginDuration='0', profileName=pn, userId=uid)  
  41.   print(x)
  1. (reply){
  2. return = "{440BF888-5809-4FC6-EDE1-4C5358DF63D6}"
  3. }

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 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