03-20-2018 01:17 PM
I am new to all of this and attempting to automate some CSS/PT creation. I am having success when I have only an item to add/create. When I need to create an item like a CSS with members I am running into issue. I am trying to use the factory.create component of SUDS to build everything I need to pass to CCM for a new CSS. Sample below:
newCSS = client.factory.create('ns0:XCss')
newCSS.name = siteName + '-CSS'
This will generate the below object for me:
(XCss){
description = None
members =
(members){
member[] = <empty>
}
partitionUsage = None
name = None
My issue is populating the tier below "members =". I am not able to get that populated in the correct format to send to CCM. This same issue repeats itself when creating a hunt group. I have tried using the schema guide but find it less than helpful. I am not able to factory.create(members) in any variation 'ns0:members' 'ns0:addMembers' etc...
I would like a sample of how this works or some guidance on how to determine the method to populate memberships when working in Python with SUDS. Any help would be greatly appreciated.
Solved! Go to Solution.
04-15-2018 12:44 PM
Working for me:
def AXLConnect():
wsdl = WSDL
location = LOCATION
UN = USERNAME
PW = PASSWORD
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)
ssl._create_default_https_context = ssl._create_unverified_context
client = Client(wsdl,location=location,faults=False, plugins=[ImportDoctor(imp)], username=UN, password=PW)
return client
def CreateHuntGroup(client):
client.factory.create('ns0:XHuntList')
lineGroup = client.factory.create('ns0:XLineGroup')
m = client.factory.create('ns0:XLineGroupMember')
m.lineSelectionOrder = 1
m.directoryNumber.pattern = '4007'
m.directoryNumber.routePartitionName = 'Phones_Pt'
lineGroup.members.member = [m]lineGroup.name = 'Function1s_2'
client.service.addLineGroup(lineGroup)def main():
client = AXLConnect()
CreateHuntGroup(client)
if __name__ == '__main__':
main()
04-14-2018 06:44 AM
I Have made some progress from the above. I am able to add a member but only in the “none” partition. When I need to specify a partition for the directory number the number is not added to the line group.
def CreateHuntGroup(client):
client.factory.create('ns0:XHuntList')
lineGroup = client.factory.create('ns0:XLineGroup')
member = client.factory.create('ns0:XLineGroupMember')
member.directoryNumber.pattern = '4001'
member.directoryNumber.routePartitionName = 'PTid-PT'
lineGroup.members = member
lineGroup.name = 'Function1s'
client.service.addLineGroup(lineGroup)
return lineGroup
Thanks all
-—-not to confuse but the codes are for two different processes. The original post was for adding a css. I was able to complete that but as I progressed I then found I was not able to reliable use members. In the recent code attachment I am using members to add a line group member and have again become stuck.
04-14-2018 06:54 AM
If you don't have to use a client factory, just add the attributes in a dict when calling the axl method.
axl = Client(wsdl_url, location=service_url, username=username, password=password)
css_kwargs = {
"name": "suds_css",
"members": {"member": [
{
"index": "1",
"routePartitionName": "Phones_Pt"
},
{"index": "2",
"routePartitionName": "Xlate_Pt"
}]
}
}
axl.service.addCss(css=css_kwargs)
Sadly, Jive's formatting stinks, but you need to supply a list of members if have more than one.
The attributes within "member" change between methods.
For Css:
<member>
<routePartitionName uuid="?">?</routePartitionName>
<index>?</index>
</member>
</members>
Compared to LineGroup:
<member>
<lineSelectionOrder>?</lineSelectionOrder>
<directoryNumber uuid="?">
<pattern>?</pattern>
<routePartitionName uuid="?">?</routePartitionName>
</directoryNumber>
</member>
And HuntGroup:
<member>
<lineGroupName uuid="?">?</lineGroupName>
<selectionOrder>?</selectionOrder>
</member>
04-15-2018 09:00 AM
Below if my lineGroup to send via client.service.addLineGroup If I send this I will have no members. If I however remove the line from any partition and send this without that section it will add a member. What am I missing?
Thanks!
lineGroup
(XLineGroup){
distributionAlgorithm = None
rnaReversionTimeOut = None
huntAlgorithmNoAnswer = None
huntAlgorithmBusy = None
huntAlgorithmNotAvailable = None
members =
(XLineGroupMember){
lineSelectionOrder = ""
directoryNumber =
(XDirn){
pattern = "4001"
routePartitionName =
(routePartitionName){
value = "PTid-PT"
_uuid = "{7A7B4C11-F9BB-6322-CEA4-BC358AB581E9}"
}
_uuid = ""
}
}
name = "ThisIsIt"
autoLogOffHunt = None
}
>>> }
Thanks!
04-15-2018 09:48 AM
Can you share a sample script?
04-15-2018 10:42 AM
from suds.client import Client
from suds.xsd.doctor import Import
from suds.xsd.doctor import ImportDoctor
import ssl
import getpass
def AXLConnect():
wsdl = 'file:///C:/Python27/AXL/AXLAPI.wsdl'
location = 'https://10.201.201.221:8443/axl/'
UN = raw_input('Enter the AXL username: ')
PW = getpass.getpass()
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)
ssl._create_default_https_context = ssl._create_unverified_context
client = Client(wsdl,location=location,faults=False,
plugins=[ImportDoctor(imp)],username=UN,password=PW)
print ' Connected to CCM'
return client
def CreateHuntGroup(client):
client.factory.create('ns0:XHuntList')
lineGroup = client.factory.create('ns0:XLineGroup')
member = client.factory.create('ns0:XLineGroupMember')
member.directoryNumber.pattern = '4001'
member.directoryNumber.routePartitionName = 'PTid-PT'
lineGroup.members = member
lineGroup.name = 'Function1s'
client.service.addLineGroup(lineGroup)
return lineGroup
client = AXLConnect()
lineGroup = CreateHuntGroup(client)
This is without the dictionary shown in prior posts.
04-15-2018 12:44 PM
Working for me:
def AXLConnect():
wsdl = WSDL
location = LOCATION
UN = USERNAME
PW = PASSWORD
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)
ssl._create_default_https_context = ssl._create_unverified_context
client = Client(wsdl,location=location,faults=False, plugins=[ImportDoctor(imp)], username=UN, password=PW)
return client
def CreateHuntGroup(client):
client.factory.create('ns0:XHuntList')
lineGroup = client.factory.create('ns0:XLineGroup')
m = client.factory.create('ns0:XLineGroupMember')
m.lineSelectionOrder = 1
m.directoryNumber.pattern = '4007'
m.directoryNumber.routePartitionName = 'Phones_Pt'
lineGroup.members.member = [m]lineGroup.name = 'Function1s_2'
client.service.addLineGroup(lineGroup)def main():
client = AXLConnect()
CreateHuntGroup(client)
if __name__ == '__main__':
main()
04-15-2018 02:11 PM
Thanks. I made this partition using another program so maybe it has a space or something I am not capturing. suggestion on a list line or list dn type code segment I can use to populate member so I am sure I don’t typo it?
Thanks again for all the help here.
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: