Below are the makings of a script to allow for debugging of your SOAP requests, and 2 functions I created (with a lot of goggling and help from others posts). def initializeSOAP(): and def linesearch (cucm_server):.
initializeSOAP(): to log into your devnet lab or other environment.
linesearch (cucm_server): takes the output from initializeSOAP() and searches for DN/Patterns in a partition and returns all possible patterns in that partition.
Please use it and comment on ways you think it could be better,
from suds.client import Client
from suds.sax.text import Raw
from suds import WebFault
import ssl
import logging
import getpass
# SOAP logging uncomment for logging output
#logging.basicConfig(filename='example.log',level=logging.CRITICAL)
#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)
def initializeSOAP():
if input('use devnet y or n ? ')=='y':
username = "hard code"
passwd = "hard code"
service_url="https://10.10.20.1:8443/axl/"
#location of WSDL
wsdl_url= "http://localhost/wsdl/AXLAPI.wsdl"
else:
username = input("enter CUCM username: ")
passwd = getpass.getpass('enter password: ')
#update with CUCM server FQDN or IP
service_url="https://<CUCM>/axl/"
#Location of WSDL
wsdl_url= "http://<server>/10.5/AXLAPI.wsdl"
input ('executing commands against %s press enter to continue or CTRL-C to exit script ' % service_url)
##to allow untrusted ssl connections
ssl._create_default_https_context = ssl._create_unverified_context
#open connection to CUCM
cucm_server = Client(wsdl_url, location = service_url, username=username , password=passwd)
return(cucm_server)
def linesearch (cucm_server):
inputPartition= input('Enter all or part of a partition: ') + '%'
inputdnOrPattern = '%'+input ('Enter all or part of the DN: ') +'%'
#static for return values
returnTagsRouteplan =[{'dnOrPattern' : '%', 'partition' : '%'}]
requestTagsRouteplan =[{'dnOrPattern' : inputdnOrPattern, 'partition' : inputPartition}]
try:
returnDNs=cucm_server.service.listRoutePlan(requestTagsRouteplan ,returnTagsRouteplan)
return (returnDNs)
except WebFault as err:
print ('error during transaction ' , err)
#input ('hold')
return ('error with finding Partition %s or DN %s, the err was %s \n' % (inputPartition,inputdnOrPattern , err))