cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
807
Views
4
Helpful
7
Replies
Highlighted
Enthusiast

Client.factory.create

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. 


Everyone's tags (4)
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Contributor

Re: Client.factory.create

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()

View solution in original post

7 REPLIES 7
Highlighted
Enthusiast

Re: Client.factory.create

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.


Highlighted
Contributor

Re: Client.factory.create

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>

Highlighted
Enthusiast

Re: Client.factory.create

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!

Highlighted
Contributor

Re: Client.factory.create

Can you share a sample script?

Highlighted
Enthusiast

Re: Client.factory.create

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. 

Highlighted
Contributor

Re: Client.factory.create

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()

View solution in original post

Highlighted
Enthusiast

Re: Client.factory.create

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.