Thursday 1 September 2016

Cisco AXL Python SUDS - Extension Mobility Remote Login

I thought I would share the following script which comes in very handy when you need to login users remotley.
The script reads a standard csv input file with the following fields -
 dn,pn,uid  
 SEP001FCA34A525,UDP_AN_OTHER,A.OTHER  

Full Script:
 __author__ = 'Mitch.Dawson'  
   
 from suds.client import Client  
   
 # Define Authentication Credentials for Cluster  
 username = 'myaxluser'  
 password = 'myaxlpass'  
   
 # Define AXL URL Parameters for Cluster  
 url = 'https://CUCM:8443/axl/'  
   
 # Define WSDL Locations  
 wsdl = "file:///C:/pathto/AXLAPI.wsdl"  
   
 # Open and read csv File  
 data = open('login.csv', 'r').read()  
   
 # Split data per line  
 splitData = data.split('\n')  
   
 # Build SUDS Client Connection  
 client = Client(location=url, url=wsdl, retxml=False, username=username, password=password)  
   
 # loop through and break out individual components  
 for line in splitData[1:]:  
   dn = line.split(',')[0]  
   pn = line.split(',')[1]  
   uid = line.split(',')[2]  
   print(dn, pn, uid)  
   
   # Call client service "doDeviceLogin" method and pass in the parameters  
   x = client.service.doDeviceLogin(deviceName=dn, loginDuration='0', profileName=pn, userId=uid)  
   print(x)