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 )
Below I have provided some sample code to use with AXL. I use the "Requests" libraries to process HTTP so if you use the below code exactly you will need to download the Requests library for python. Also, and I am sure you know this, but please change your keep your AXL version consistent with the CUCM you are using. The below code is using AXL 8.5. Let me know if you have any questions.
import requests
import xml.etree.ElementTree as ET
soaprequest = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.cisco.com/AXL/API/8.5"><soapenv:Header /><soapenv:Body><ns:listPhone><searchCriteria><name>SEP%</name></searchCriteria><returnedTags><name></name></returnedTags></ns:listPhone></soapenv:Body></soapenv:Envelope>'
soapheaders = {'Content-type':'text/xml', 'SOAPAction':'CUCM:DB ver=8.5 listPhone'}
AXLRequest = requests.post('https://CMServer:8443/axl/', data = soaprequest, headers = soapheaders, verify = False, auth=('username','password'))
root = ET.fromstring(AXLRequest.text)
DeviceNames = []
for phone in root.iter('phone'):
DeviceNames.append(phone.find('name').text)
#print phone.find('name').text
print DeviceNames
Thx Kristopher, that's indeed working and a good first step ;-)
Kind of complicated, though. I do use quite a few methods and with the php SoapClient, i can just load the connection with the xdml file and give the parameters in a nice array / list ... and get the stuff back in sort of a nice way.
So if anyone can give a working example using SUDS, that would be perfect.
I did find something that's working in Python2 for the RIS interface:
Parky's Place: Using Python to call Cisco Communications Manager Serviceability SOAP API
Havent' been able to port that to work with AXL though ...
For what it's worth, I've tried AXL with Python Suds and pysimplesoap. Suds seems to create XML that AXL doesn't like, and I get this error when I try to use an API:
AttributeError: 'NoneType' object has no attribute 'promotePrefixes'
I get a little farther with Pysimplesoap, but in the end I haven't figured out how to call an API. Here's code to get you started, though, if you're interested (substitute your own username, password, and server, and point to the place where you have the WSDL and XSDs):
from pysimplesoap.client import SoapClient
import base64
wsdl="http://localhost/AXLAPI.wsdl"
location="https://server:8443/axl"
action="https://server:8443/axl"
ns='http://schemas.cisco.com/ast/soap/'
username="username"
password="password"
toencode=username + ':' + password
encoded=base64.b64encode(bytes(toencode,"utf-8"))
client = SoapClient(wsdl=wsdl, location=location, action=action, ns=ns, http_headers={'Authorization': 'Basic %s' % encoded})
print(client.help('listPhone'))
try this Python SUDS code. I am running this on Python 2.7.8 on Windows 7
from suds.client import Client
cmserver = '10.10.10.10'
cmport = '8443'
wsdl = 'file:///your/system/path/schema/current/AXLAPI.wsdl'
location = 'https://' + cmserver + ':' + cmport + '/axl/'
username = 'username'
password = 'password'
client = Client(wsdl,location=location, username=username, password=password)
result = client.service.listPhone({'name':'SEP%'},{'name':'','model':''})
for node in result['return']['phone']:
print str(node['name']), str(node['model'])
I am getting below error when i am running given code:
result = client.service.listPhone({'name':'SEPEXXXXD958F06'},{'name':'','model':''})
print(result)
for node in result['return']['phone']:
print str(node['name']), str(node['model'])
************
(200, (reply){
return =
(return){
phone[] =
(LPhone){
_uuid = "{51D5AC0A-E3F9-C05B-B446-4F1ACD6D0472}"
name = "SEPEXXXXD958F06"
model = "Cisco 7945"
},
}
})
Traceback (most recent call last):
File "C:\Python27\Scripts\Listphone1.py", line 58, in <module>
for node in result['return']['phone']:
TypeError: tuple indices must be integers, not str
Waw, i think i have figured it out ... but it's a bit a painful one. Got it working for get* methods too now, list is working also (as it always did), still have to try add* stuff.
So, here's how it goes:
- Windows7 (shouldn't matter that much) and Python3.4.2
- install suds-jurko with pip
- PATCH the file (not kidding) C:\Python34\Lib\site-packages\suds\bindings\document.py
you just need to comment out line 141:
if not child.isattr():
(there's only one line like this, so you can't miss) - TADAA, all is working. if i understand it correct, suds does not pull in 'optional' stuff from wsdl and with the above patch it should do that now
As I don't know suds at all, here's a very rudimentary example for a get* request (pretty much based on the answers above ;p)
wsdl = 'file:///C:/path/to/your/matching/AXLAPI.wsdl'
from suds.client import Client
client = Client(wsdl,location='https://yourserverhere:8443/axl/',username='yourusername',password='yourpassword')
phone = client.service.getPhone(name='test')
print(phone)
(reply){
return =
(return){
phone =
(RPhone){
_uuid = "{50BCA715-C781-C8B0-CC90-E0B95CB2F1AD}"
_ctiid = 9
name = "jseynaev-test"
description = "jseynaev-test"
product = "Cisco IP Communicator"
< ... very long list of params ... >
Let me know if this works for you too!
I did a pip install suds-jurko with Python34, and it didn't install C:\Python34\Lib\site-packages\suds\bindings\document.py. I believe everything necessary is packed in the egg file, and I didn't extract it or edit document.py there.
However, the following code still worked fine for me:
from suds.client import Client
from suds.transport.https import HttpAuthenticated
cmserver = 'server'
cmport = '8443'
wsdl = 'PATH/TO/AXLAPI.wsdl'
location = 'https://' + cmserver + ':' + cmport + '/axl/'
username = 'username'
password = 'password'
client = Client(wsdl,location=location, transport = HttpAuthenticated(username=username, password=password))
result = client.service.listPhone({'name':'SEP%'},{'name':'','model':''})
for node in result['return']['phone']:
print (str(node['name']), str(node['model']))
Yes, the list* calls seem to work fine 'out of the box', however, things like getPhone or getRegion (try e.g. region = client.service.getRegion(name='Default')) throw an error of some non-defined property ...
Not sure how the whole pip install works, but for me that's where the file was, maybe it installed it somewhere in your home directory? (i choose to install 'for everyone on this pc')
This works for me in the above example in place of listPhone:
result = client.service.getPhone(name='SEP010101010101')
print(result)
I tried various ways of specifying returnedTags, but nothing I tried worked. Suds is not extremely well documented when it comes to using a WSDL like AXLAPI. By the way, I'm using the 10.5 WSDL against a 10.5 CUCM.
I agree with Nick. There is not a lot of documentation for using AXL with suds or any other python soap handlerfor that matter, even pysimplesoap. His assessment is also correct with usage of tags. Trying to find out exactly what works with suds was a little difficult. when I posted my code in my last post the only way I was able to figure it out for the listPhone was through a little trial and error with the tags. Also, I was able to get it to work without patching the file you mentioned
I think depending on the call you are using you might have to adjust how you write the tags, so you might have a little trial and error on that one. which would be a benefit in the future maintaining your code. That being said you could always use the old fashioned way like my very first post on this thread, depends on your preference and how simple or complex you want to make it considering your trade offs of time and how mush maintenance you are willing to do to your code.
Below is the final code sample I have combining Nick's testing and my own. Let us know if that works for you or if you are having trouble with any other calls in AXL.
from suds.client import Client
cmserver = '10.10.10.10'
cmport = '8443'
wsdl = 'file:///your/file/location/schema/current/AXLAPI.wsdl'
location = 'https://' + cmserver + ':' + cmport + '/axl/'
username = 'user'
password = 'pass'
client = Client(wsdl,location=location, username=username, password=password)
result = client.service.getPhone(name = 'IPCMRAEU5UCM5X7')
print result
I forgot to mention that in my last post the code is utilizing the 9.1 version of AXL.
I suspect the <returnedTags> element is required for those requests:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.cisco.com/AXL/API/10.5">
<soapenv:Header/>
<soapenv:Body>
<ns:getPhone sequence="1">
<name>IPCMRAEU5UCM5X7</name>
<returnedTags>
<name/>
</returnedTags>
</ns:getPhone>
</soapenv:Body>
</soapenv:Envelope>
did you ever get the answer you were looking for?.
I hope you are having a good day.
Yes, as I stated in my earlier post, if I do that patch, all is working fine...
Pretty much agree on all of the above, it's a bit of trial and error, indeed.
Pretty good info here, looks like your still the man Jan . Thanks ALL for the use full tips! I managed to get python talking to AXL. I had some errors around SSL, so i used urllib for the authentication. Should be able to use the SSL cert for authentication with minimal modifications. Hopefully this can save someone else from bashing their head against a wall
#Environment
#Centos7/UCM8.5/Python3/suds-jurko
#Note no patching of the file was required, I used the suds-jurko(0.6) from pip install.
#http://smirnov-am.blogspot.com.au/2015/04/monitoring-device-registration-with.html
#got the SSL workaround from above blog
import ssl
import urllib
from suds.transport.https import HttpAuthenticated
from suds.client import Client
t = HttpAuthenticated(username='AXL_USER', password='axlPass')
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)
wsdl = 'file:///path/to/your/axl/file/axlsqltoolkit/schema/8.5/AXLAPI.wsdl'
client=Client(wsdl, location='https://10.1.1.1:8443/axl/', transport=t)
#Usage
phone = client.service.getPhone(name='SMITH-TEST')
print(phone['return']['phone']['lines']['line'][0]['dirn']['pattern'])
86116094
phones = client.service.listPhone({'devicePoolName':'CNT_DP'},{'name':'','model':''})
for i in phone['return']['phone']:
print(i['name'], i['model'])
dp = client.service.listDevicePool({'name':'%'},{'name':''})
for i in dp['return']['devicePool']:
print(i['name'])
Will try out some add methods now and see how that goes.
Have you had any luck adding phones or phone profiles with Python/Suds. If so is it possible to share the code please ?
For example to add a phone I have tried a number of combinations here is one;
ap = client.service.addPhone({
"name" : "AAAABBBBCCCCDDDD",
"product": "Cisco 7975",
"class": "Phone",
"protocol": "SCCP",
"protocolSide": "User",
"devicePoolName": "test_dp",
"commonPhoneConfigName": "Standard Common Phone Profile",
"locationName": "Hub_None",
"securityProfileName": "Cisco 7975 - Standard SCCP Non-Secure Profile",
})
Everything I have tried has failed. Any help would be appreciated.
I am attaching the code below that worked for me. I needed to add a few elements to make it work. A little trial and error, but you could always try to do a little pruning if you see any elements I have included that you think are not necessary. I also included some debugging function which I have always found useful. Just be careful what you turn on to be at the DEBUG level, you may get more than you bargain with if you set everything to DEBUG.
from suds.xsd.doctor import Import
from suds.xsd.doctor import ImportDoctor
from suds.client import Client
from suds.transport.https import HttpAuthenticated
import logging
cmserver = 'your.cucm.com'
cmport = '8443'
wsdl = 'file:///Your/location/ofWSDL/axlsqltoolkit10(5)/schema/current/AXLAPI.wsdl'
location = 'https://' + cmserver + ':' + cmport + '/axl/'
username = <USERNAME>
password = <PASSWORD>
logging.basicConfig(level=logging.CRITICAL)
logging.getLogger('suds.client').setLevel(logging.DEBUG)
logging.getLogger('suds.transport').setLevel(logging.DEBUG)
logging.getLogger('suds.xsd.schema').setLevel(logging.CRITICAL)
logging.getLogger('suds.wsdl').setLevel(logging.CRITICAL)
client = Client(wsdl,location=location, username=username, password=password)
#print client
result = client.service.addPhone({'name':'SEP018888675309','class':'Phone','product':'Cisco 7975','protocol':'SCCP',
'protocolSide':'User','devicePoolName':'Default',
'commonPhoneConfigName':'Standard Common Phone Profile',
'locationName':'Hub_None','securityProfileName':'Cisco 7975 - Standard SCCP Non-Secure Profile',
'useTrustedRelayPoint':'Default','presenceGroupName':'Standard Presence Group','phoneTemplateName':'Standard 7975 SCCP',
})
print result
Thank you Jock ! that worked Looks like I wasn't using a valid mac add (slaps face)
I did a bit of experimenting and found this to be the least number of elements that can be used for 7975
#add Phone
ap = client.service.addPhone({
'name': 'SEPAAAABBBB2222',
'product': 'Cisco 7975',
'class': 'Phone',
'protocol': 'SCCP',
'devicePoolName': 'test_dp',
})
note that I am using ucm10.5 for my test server.
Bradley, Awesome, I am glad that worked for you. Thanks for finding out the least number elements required for adding a 7975 phone. that will come in handy. I am also running this against 10.5 I might give it a shot against the 9.1 and 10.0 servers in our lab just to make sure that works as well. Probably will, but you never know.
Your code really does the trick! I have been playing with it but for some reason when I try a getPhone the suds parser adds some extra tags to the SOAP request.
I am using python version 2.7 and suds .4 (don't know if you might be working with different versions)
For example if I try this:
result = client.service.getPhone({'name':'CSFDEMOJABBER'})
print result
suds generates something like this:
<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-ENV:Header/>
<ns1:Body>
<ns0:getPhone>
<returnedTags>
<name>CSFDEMOJABBER</name>
</returnedTags>
</ns0:getPhone>
</ns1:Body>
</SOAP-ENV:Envelope>
This fails cause returnTags shouldn't be there.
If you remove those returnedTags the SOAP request works without any problems
I have been looking around and seems that you can modify the SOAP request before sending it to CUCM but haven't had any luck yet.
python - Incorrect XML produced by SUDS - Stack Overflow
python - Suds generates empty elements; how to remove them? - Stack Overflow
UPDATE
Got it working!! I had to use the messageplugin in suds in order to modify the soap message before it is sent to CUCM
in the client request you have to add the plugin
client = Client(wsdl,location=location, transport=t, plugins=[MyPlugin()])
then I look for the child inside the body of the message and rename it to 'name'
class MyPlugin(MessagePlugin):
def marshalled(self, context):
body = context.envelope.getChild('Body').getChild('getPhone').getChild('returnedTags')
body.rename('name')
maybe is not that "clean" but it works for me, hope it helps someone.
Not sure what you are trying to achieve, but if you want to get a single phone details, you can do it by
result = client.service.getPhone(name='CSFDEMOJABBER')
If you want to only get specific info, you can use listPhones and pass a dictionary with the returnedTags argument
client.service.listPhone({'name':'SEP111111111111'}, returnedTags={'callingSearchSpaceName':'', 'description':''})
Thanks for the very helpful information!
I'm trying to do the same to add a CSS with partitions but I'm not sure of the syntax. Anyone have any input on this?
# Add CSS
css_result = client.service.addCss({'name':'CSS_TEST',
'description':'CSS_TEST_DESC',
'members'{'member'{'routePartitionName':'PT_TEST','index':'1'}}
})
print css_result
Getting a syntax error.
SyntaxError: invalid syntax
'members'{'member'{'routePartitionName':'PT_TEST','index':'1'}}
^
SyntaxError: invalid syntax
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
Thanks ! 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.
####################################################
# Add Route Partition - Working
pt_result = client.service.addRoutePartition({'name':'PT_TEST',
'description':'PT_TEST_DESC',
'useOriginatingDeviceTimeZone':'true',
})
print pt_result
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.
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.
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'
)
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'
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 ?
yes that's correct. 2.7 on Windows and CUCM is 10.5.2.
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)
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'
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.
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).'
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
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)
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.
Don't have a Suds example, but if it helps attaching a (rather inelegant) Python script I put together to bulk-create a bunch of users/lines/phones - it just uses XML templates and .format() manipulations to handle the variables.
Thanks for the example will have a look at see what I can get together, it seems like I may end up using suds and requests to get what I want done.
Not sure what's up with the update issue. You mentioned using the suds doctor? Did that work for you with CUCM 10.5? Is there anything special you used to get it working?
Wow. Thank you everyone for your detailed examples. It's reassuring to know I am not in the Python AXL boat all alone. This has been a frustrating few weeks as I tip toe through the the API. I have had some of the same frustations as you, but there is one in particular that's driving me crazy.
I want to change the routing for a route list. Basically, I have a route list for a site (Site A) with 3 route list members (Site A, Site B, Site C - in that order) and I want to change it Site B, Site C, Site A.
I thought I could do it with the AXL api but I can't find a way to list them route list members.
Any ideas?
I should have mentioned it, but I am running CUCM 9.1
Give this a try, I just tested it and it updates route list in v8.6, I don't have 9.1 to test, but it should be similar if different.
Just change the selection order to the order that you want the route groups in the list.
For example, originally I had ABC_RG in position 1 and TSTING_RG in position 3, when I ran this code, ABC_RG was in position 3 and TSTING_RG was in position 1
client.service.updateRouteList(
name='TST_RL',
members={'member': [{
'selectionOrder' : 1,
'routeGroupName': 'TSTING_RG'
}, {
'selectionOrder' : 2,
'routeGroupName': 'BRI_RG'
}, {
'selectionOrder' : 3,
'routeGroupName': 'ABC_RG'
}]
})
Thanks for the code, but unfortunately, it didn't work. I'm getting the following errors:
Server raised fault: no uuid or name element found
No handlers could be found for logger "suds.client"
I ran into this problem when trying to list the route members and I thought the problem had to due with a lack of searchCriteria in the WSDL.
The complete code looks like this:
cmserver = myserver'
cmport = '8443'
wsdl = 'file:///c:/axlapi/schema/9.1/AXLAPI.wsdl'
location = 'https://' + cmserver + ':' + cmport + '/axl/'
username="username"
password="password"
client = Client(wsdl,location=location, username=username, password=password)
client.service.updateRouteList(
name=my_RL',
members={'member': [{
'selectionOrder' : 1,
'routeGroupName': apple_RG'
}, {
'selectionOrder' : 2,
'routeGroupName': blueberry_RG'
}, {
'selectionOrder' : 3,
'routeGroupName': cherry_RG'
}]
})
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
After some more digging - and looking at other posts on this thread, I adopted an alternate approach
def updateRouteList (device):
SOAP = '<SOAP-ENV:Envelope xmlns:ns0="http://www.cisco.com/AXL/API/9.1" 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:updateRouteList>'
SOAP += '<name>' + device + '</name>'
SOAP += '<description>my description</description>'
SOAP += '<addMembers><member><selectionOrder>4</selectionOrder><routeGroupName>XYZ-PSTN_RG</routeGroupName></member></addMembers>'
SOAP += '<removeMembers><member><selectionOrder>3</selectionOrder><routeGroupName>BCD-PSTN_RG</routeGroupName></member></removeMembers>'
SOAP += '</ns0:updateRouteList>'
SOAP += '</ns1:Body>'
SOAP += '</SOAP-ENV:Envelope>'
return SOAP
This changes the routeList description, adds a new routeGroup (XYZ-PSTN_RG) and deletes another RG (BCD-PSTN_RG).
I suppose one way of reordering the list is to remove all the member routeGroups and then add them to RL in their new order.
Unless someone else has a better idea....
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Comments
0 comments
Please sign in to leave a comment.