python client for AXL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2014 07:19 AM
Hello,
I have a nice working toolset that is interacting very well with AXL interface using PHP.
However, we are looking to switch to python (it does look like this would be a lot easier to process data coming in). Unfortunately, i can't find any working example to connect to the AXL interface.
suds seems to be the way to go, but that's not working on python3. I'm happy doing this in python2, but still, i don't get suds to get the works done ... any working example is welcome! (i'll give you a working PHP example in return ;p )
Jan.
- Labels:
-
AXL

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2015 06:48 PM
Give this a try Travis
css_result = client.service.addCss({'name':'CSS_TEST',
'description':'CSS_TEST_DESC',
'members': {'member': [{
'routePartitionName': 'PT_TEST',
'index': '1'
},{
'routePartitionName':'PT_TEST_2',
'index': '2'
}]
}
})
print css_result

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2015 07:27 PM
Thanks Brad! That worked great!
I'm trying to build a full site deployment script via python and axl and this has been a great starting point. Any more examples someone has already done? I will share as I go along as well.
Thanks again!
####################################################
# Add Route Partition - Working
pt_result = client.service.addRoutePartition({'name':'PT_TEST',
'description':'PT_TEST_DESC',
'useOriginatingDeviceTimeZone':'true',
})
print pt_result

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2015 07:47 PM
No Worries,
I have recently finished the same thing you are working on now . It was a fun exercise but oft frustrating.
let me know anything you get stuck on and ill help out if I have an example.
Cheers,
Brad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2015 04:55 PM
Hi Brad,
Trying to do an updateDevicePool and getting an error.
suds.TypeNotFound: Type not found: 'mediaResourceListName'suds.TypeNotFound: Type not found: 'mediaResourceListName'
I'm not sure why its throwing the error as I know the field exists and so do the MRGL and RGs.
print result
result = client.service.updateDevicePool(
{'name':'DP_'+site,
'mediaResourceListName':'MRGL_TEST',
'localRouteGroup':
[{
'value':'RG_TEST',
'name':'Standard Local Route Group'
}]
})
print result
This is however the first update I have tried doing.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2015 06:07 PM
Hey Travis,
The syntax is a little different with updating, this should get you out of trouble.
result = client.service.updateDevicePool(
name='DP_'+site,
localRouteGroupName='RG_TEST',
mediaResourceListName='MRGL_TEST'
)
Cheers,
Brad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2015 06:44 PM
Hmm tried that and its actually sending the request now but I'm getting a new error. I don't see the name being sent in the SOAP envelope now.
result = axl.client.service.updateDevicePool(
name = 'DP_API_FnA68',
mediaResourceListName = 'MRGL_API_FnA68'
)
print result
Traceback (most recent call last):
File "updateDevicePool.py", line 19, in <module>
mediaResourceListName = 'MRGL_API_FnA68'
File "C:\Python27\lib\site-packages\suds\client.py", line 542, in __call__
return client.invoke(args, kwargs)
File "C:\Python27\lib\site-packages\suds\client.py", line 602, in invoke
result = self.send(soapenv)
File "C:\Python27\lib\site-packages\suds\client.py", line 649, in send
result = self.failed(binding, e)
File "C:\Python27\lib\site-packages\suds\client.py", line 702, in failed
r, p = binding.get_fault(reply)
File "C:\Python27\lib\site-packages\suds\bindings\binding.py", line 265, in get_fault
raise WebFault(p, faultroot)
suds.WebFault: Server raised fault: 'No uuid or name element found'

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2015 07:19 PM
Works fine for me on UCM 8.6, im firing up 10.5 to test out.
Whats your environment ? Looks like you are running python 2.7 on Windows ? Whats your CUCM version is it 10.5 ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2015 07:21 PM
yes that's correct. 2.7 on Windows and CUCM is 10.5.2.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2015 07:43 PM
Ok I tried on 10.5.2 and its working fine, im using linux and python3 and suds-jurko (are you using suds-jurko?), so my environment is a bit different to yours.
Are you using the suds doctor ? That is something that i am now using which was not mentioned in my previous post. That might help if you are not using it give it a try.
import ssl
import urllib
from suds.transport.https import HttpAuthenticated
from suds.client import Client
from suds.client import WebFault
from suds.xsd.doctor import Import
from suds.xsd.doctor import ImportDoctor
tns = 'http://schemas.cisco.com/ast/soap/'
imp = Import('http://schemas.xmlsoap.org/soap/encoding/', 'http://schemas.xmlsoap.org/soap/encoding/')
imp.filter.add(tns)
t = HttpAuthenticated(username='AXL_USER', password='AXL_PASS')
t.handler = urllib.request.HTTPBasicAuthHandler(t.pm)
ssl_def_context = ssl.create_default_context()
ssl_def_context.check_hostname = False
ssl_def_context.verify_mode = ssl.CERT_NONE
t1 = urllib.request.HTTPSHandler(context=ssl_def_context)
t.urlopener = urllib.request.build_opener(t.handler, t1)
# CUCM 10.5
# wsdl = 'file:///path/to/your/wsdl/axlsqltoolkit/schema/10.5/AXLAPI.wsdl'
# client=Client(wsdl, location='https://tstcm01:8443/axl/', faults=False, plugins=[ImportDoctor(imp)], transport=t)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2015 08:16 PM
Having this issue with the updatePhone also.
phone = raw_input('Enter Phone Name: ')
result = axl.client.service.updatePhone(
name = phone,
callingSearchSpaceName = 'CSS_API_FnA68',
)
print result
suds.WebFault: Server raised fault: 'No uuid or name element found'

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2015 09:38 PM
Hi travisr,
I have been working with CUCM 10.5.1 and got the same problem with updates, looks like suds adds or skips some code in the envelope and CUCM does not like that and returns a 5003 axl code, I got around it creating my own XML envelope and sending it in the request via inject message.
This works for me:
def updatePhone (device,owner):
SOAP = '<SOAP-ENV:Envelope xmlns:ns0="http://www.cisco.com/AXL/API/10.5" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">'
SOAP += '<SOAP-ENV:Header/>'
SOAP += '<ns1:Body>'
SOAP += '<ns0:updatePhone>'
SOAP += '<name>' + device + '</name>'
SOAP += ' <ownerUserName>' + owner +'</ownerUserName>'
SOAP += '</ns0:updatePhone>'
SOAP += '</ns1:Body>'
SOAP += '</SOAP-ENV:Envelope>'
return SOAP
#Updates endpoint with users
result = client.service.updatePhone(__inject={'msg':updatePhone(SEP,USER)})
I have used it with updatePhone and updateUser and so far the script is working fine.
Let me know how it goes.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2015 08:10 PM
Thanks Eder! I got that working using your example!
I have another issue going on with adding translation patterns.
site = raw_input('Enter Sitecode: ')
npa = raw_input('Enter the npa for the site (area code): ')
nxx = raw_input('Enter the nxx for site (city code): ')
pattern = raw_input('Enter Last 4 digits DID block for the site: ')
CPTM = npa+nxx+pattern
result = axl.client.service.addTransPattern(
{'pattern':pattern,
'routePartitionName':site,
'callingSearchSpaceName':'CSS_'+site,
'description':'Translate 4 to 10 digits '+npa+nxx+pattern,
'calledPartyTransformationMask':CPTM})
print result
Traceback (most recent call last):
File "addTranslationPattern.py", line 24, in <module>
'calledPartyTransformationMask':CPTM})
File "C:\Python27\lib\site-packages\suds\client.py", line 542, in __call__
return client.invoke(args, kwargs)
File "C:\Python27\lib\site-packages\suds\client.py", line 602, in invoke
result = self.send(soapenv)
File "C:\Python27\lib\site-packages\suds\client.py", line 649, in send
result = self.failed(binding, e)
File "C:\Python27\lib\site-packages\suds\client.py", line 702, in failed
r, p = binding.get_fault(reply)
File "C:\Python27\lib\site-packages\suds\bindings\binding.py", line 265, in get_fault
raise WebFault(p, faultroot)
suds.WebFault: Server raised fault: 'Cannot insert a null into column (numplan.tkpatternusage).'

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2015 08:36 PM
Hey Travis,
add;
'usage': 'Translation',
into your dictionary.
FYI I replyed to your other post but it has been waiting for moderation for 2 days now.
You can try using the suds doctor that might help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2015 08:38 PM
from suds.xsd.doctor import Import
from suds.xsd.doctor import ImportDoctor
client=Client(wsdl, location='Your call manager url', faults=False, plugins=[ImportDoctor(imp)], transport=t)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2017 01:41 PM
Hi Brad,
I know this is an old post but there are lots of useful examples on here. I am trying to write some Python code to carry out various tasks using AXL, using Suds-Jerko. I wonder if you have an example code of how to add a phone and line. I can add the phone no problems, but am struggling to associate a line with the phone. I am using CUCM 10.5 to test against.
Thanks in advance.
Glen
