08-02-2018 08:45 PM
Trying to add a trunk port using Pythons and suds to do it. Question is I do not know how to tell it to program the destination in the IPV4 address area within the added trunk call. Below is a sample of a working sip profile and the none work add sip trunk.
code that works:
# Add Sip Profile
print("")
print("Adding SIP Profile to Call Manager")
print("")
client = Client(wsdl,location=location, username=username, password=password)
ap = client.service.addSipProfile({
'name': sProfileName + " Cisco Unity SIP Profile",
'description' : sProfileName + " Cisco Unity SIP Profile",
'enableOutboundOptionsPing': 'True'
})
print("Command completed successfully! ")
code that does not work.
# Add Sip Trunk
print("")
print("Adding SIP Trunk to Call Manager")
print("")
client = Client(wsdl,location=location, username=username, password=password)
ap = client.service.addsipTrunk({
'name' : sProfileName + " Cisco Unity SIP Trunk",
'description' : sProfileName + " Cisco Unity SIP Trunk",
'devicePoolName' : "Phoenix",
'location' : "Phoenix",
'sipProfileName' : sProfileName + " Cisco Unity SIP Trunk",
'securityProfileName' : sProfileName + " Cisco Unity SIP Trunk",
'addressIpv4' : "10.10.10.10"
})
Error with code:
Traceback (most recent call last):
File "C:/Users/rwykoff/Documents/testing/voiceadd.py", line 38, in versioncheck
login(wsdl,location,username,password,imp)
File "C:/Users/rwykoff/Documents/testing/voiceadd.py", line 123, in login
mainMenu(wsdl,location,username,password,imp)
File "C:/Users/rwykoff/Documents/testing/voiceadd.py", line 148, in mainMenu
addCiscoUnity(wsdl,location,username,password,newbuild)
File "C:/Users/rwykoff/Documents/testing/voiceadd.py", line 279, in addCiscoUnity
'addressIpv4' : "10.10.10.10"
File "C:\Program Files\Python36\lib\site-packages\suds\client.py", line 521, in __call__
return client.invoke(args, kwargs)
File "C:\Program Files\Python36\lib\site-packages\suds\client.py", line 576, in invoke
soapenv = binding.get_message(self.method, args, kwargs)
File "C:\Program Files\Python36\lib\site-packages\suds\bindings\binding.py", line 109, in get_message
content = self.bodycontent(method, args, kwargs)
File "C:\Program Files\Python36\lib\site-packages\suds\bindings\document.py", line 95, in bodycontent
add_param, self.options().extraArgumentErrors)
File "C:\Program Files\Python36\lib\site-packages\suds\argparser.py", line 83, in parse_args
return arg_parser(args, kwargs, extra_parameter_errors)
File "C:\Program Files\Python36\lib\site-packages\suds\argparser.py", line 108, in __call__
self.__process_parameters()
File "C:\Program Files\Python36\lib\site-packages\suds\argparser.py", line 299, in __process_parameters
self.__process_parameter(*pdef)
File "C:\Program Files\Python36\lib\site-packages\suds\argparser.py", line 294, in __process_parameter
self.__in_choice_context(), value)
File "C:\Program Files\Python36\lib\site-packages\suds\bindings\document.py", line 86, in add_param
p = self.mkparam(method, pdef, value)
File "C:\Program Files\Python36\lib\site-packages\suds\bindings\document.py", line 130, in mkparam
return Binding.mkparam(self, method, pdef, object)
File "C:\Program Files\Python36\lib\site-packages\suds\bindings\binding.py", line 225, in mkparam
return marshaller.process(content)
File "C:\Program Files\Python36\lib\site-packages\suds\mx\core.py", line 59, in process
self.append(document, content)
File "C:\Program Files\Python36\lib\site-packages\suds\mx\core.py", line 72, in append
self.appender.append(parent, content)
File "C:\Program Files\Python36\lib\site-packages\suds\mx\appender.py", line 88, in append
appender.append(parent, content)
File "C:\Program Files\Python36\lib\site-packages\suds\mx\appender.py", line 229, in append
Appender.append(self, child, cont)
File "C:\Program Files\Python36\lib\site-packages\suds\mx\appender.py", line 168, in append
self.marshaller.append(parent, content)
File "C:\Program Files\Python36\lib\site-packages\suds\mx\core.py", line 71, in append
if self.start(content):
File "C:\Program Files\Python36\lib\site-packages\suds\mx\literal.py", line 86, in start
raise TypeNotFound(content.tag)
suds.TypeNotFound: Type not found: 'location'
Thanks in Advance.
08-26-2020 01:41 PM
My guess would be that this line may be missing from the 'imports' area of the app:
from zeep.exceptions import Fault
The error indicates it can't find an object/variable named 'Fault', which should be provided by the import.
In turn, this error is probably masking the actual error, which is something bad happening with the request itself. You might enable the debug output to see if you can see anything in the raw request/response that jumps out at you. Probably correcting the Fault name error above will also bubble up the more detailed actual error message...
08-26-2020 10:50 PM
Great.
import Fault resolved my issue.
Thank You.
Any idea about my second query ?
Any option to perform bulk jobs please?
08-27-2020 09:21 AM
Managing the CUCM 'BAT' bulk-management stuff is not possible via AXL. You might be able to scrape/reverse engineer all the HTTP requests that occur when performing those actions in the CUCM admin via browser, but that would not be officially supported.
It is theoretically possible to use AXL <executeSqlUpdate> to perform SQL operations that affect bulk operations like INSERT, or simply include multiple SQL actions in the same AXL request (separated by ';'), however this will require some detailed study of the CUCM database tables/fields/relationships, and skill in authoring SQL (see the Data Dictionary). This is often not very effective: as CUCM data is highly normalized, with dozens of separate tables contributing to the typical configuration of an end-user for example, it is pretty rare I think to find a situation where you want to add a large number of rows to one specific table. With one AXL <addUser> request, you can provide a bunch of data for the user that ends up getting inserted into multiple tables automatically.
02-25-2020 08:05 AM
addressIpv4 should be within two levels of parent tags. Here's the XML representation:
<destinations>
<!--0 to 16 repetitions:-->
<destination>
<!--Optional:-->
<addressIpv4>?</addressIpv4>
</destination>
</destinations>
Suds is also a fairly outdated way to handle SOAP/AXL. I find it difficult to use. Take a look at Zeep - it's much easier.
02-25-2020 07:42 PM
I tried using zeep and ciscoaxl but I was not able to achieve updating MRGL field in device pool (Other parameters like region, location, etc. works fine)
Anybody know how to configure Region Relationships using python ?
Also how to add location and physical location using Python ?
Thanks.
Vikas
02-27-2020 01:36 PM
Added examples for <addRegion> and <addLocation> to the repo here: https://github.com/CiscoDevNet/axl-python-zeep-samples
Physical Location has only a single 'name' attribute, so it should be trivial to implement based on any of those samples.
04-23-2020 02:11 AM
Is it possible to add phone template using zeep ?
I managed to add other stuff and now trying to do bulk phone addition using python but I'm not sure if this is doable ?
Please suggest.
Vikas
05-15-2020 06:38 PM - edited 05-20-2020 05:18 AM
I'm trying to get the details of a SIP trunk in CUCM 12.5 using the ciscoaxl module and zeep, and then create a spreadsheet from the output. I have it all working with the exception of pulling the destination IP address, as I am unable to capture that field in the output. I also noted that I had to use the tagfilter option to return the other relevant fields since they are mostly muted by default to save on memory usage. Here is a code sample:
with open(str_FileSavePathTrunkCSV, 'w') as csvfile:
w = csv.writer(csvfile)
w.writerow(['SIP Trunk Name', 'Inbound CSS', 'SIP Profile', 'SIP Trunk Security Profile', 'Destination IP address'])
for trunk in ucm.get_sip_trunks(tagfilter={"name":"","callingSearchSpaceName":"","sipProfileName":"","securityProfileName":"","destination":""}):
lst_linecsv = ({1:trunk.name, 2:trunk.callingSearchSpaceName._value_1, 3:trunk.sipProfileName._value_1, 4:trunk.securityProfileName._value_1, 5:trunk.destination})
w = csv.writer(csvfile)
#w = csv.writer(sys.stderr)
w.writerow(lst_linecsv.values())
Does anyone know how to extract the IP address (destination) from the SIP trunk data using the format I have listed above? When I looked at LSipTrunk() I didn't see destination as a returnable attribute, so I may be outta luck..
Solution Found:
In case anyone is following this thread and my previous question I ran the LSipTrunk() function to extract the name value, and I stored the name into a variable. then as part of a For loop I inputted the name variable into the get specific trunk function, allowing me to pull the Destination IP and several other specific data points that weren't available in the list output.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide