cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
687
Views
2
Helpful
7
Replies

Axl python script adding sip trunk

kyrunner
Level 1
Level 1

Trying to add a sip trunk using Axl and python but hitting an error call manager 11.5 

 

 Error creating SIP Trunk 'cube': ENUM for DeliverOriginatingCalledPartyNumber not found in TypeSIPIdentityBlend

 

def create_sip_trunk_cube(service
    try:
        service.addSipTrunk({
            'name': 'cube',
            'description': 'SIP Trunk to CUBE',
            'product': 'SIP Trunk',
            'class': 'Trunk',
            'devicePoolName': 'school1',  # Reference the existing 'school1' device pool
            'protocol': 'SIP',
            'protocolSide': 'Network',
            'callingSearchSpaceName': 'pstninbound_CSS',
            'sipProfileName': 'Standard SIP Profile',
            'securityProfileName': 'Non Secure SIP Trunk Profile',
            'destinations': {
                'destination': {
                    'addressIpv4': 'xxx.xxx.x.xx',
                    'port': '5060',
                    'sortOrder': '1'
                }
            },
            'locationName': 'Hub_None',
            'presenceGroupName': 'Standard Presence group',
            'callingAndCalledPartyInfoFormat': 'DeliverOriginatingCalledPartyNumber'
        })
        print("SIP Trunk 'cube' created successfully.")
    except Exception as e:
        print(f"Error creating SIP Trunk 'cube': {e}")
1 Accepted Solution

Accepted Solutions

kyrunner
Level 1
Level 1

I fixed it here was the final code for the sip trunk 

def create_sip_trunk_cube(service
    try:
        service.addSipTrunk({
            'name': 'cube',
            'description': 'SIP Trunk to CUBE',
            'product': 'SIP Trunk',
            'class': 'Trunk',
            'devicePoolName': 'school1',  # Reference the existing 'school1' device pool
            'protocol': 'SIP',
            'protocolSide': 'Network',
            'callingSearchSpaceName': 'pstninbound_CSS',
            'sipProfileName': 'Standard SIP Profile',
            'securityProfileName': 'Non Secure SIP Trunk Profile',
            'destinations': {
                'destination': {
                    'addressIpv4': 'xxx.xxx.xx.x',
                    'port': '5060',
                    'sortOrder': '1'
                }
            },
            'locationName': 'Hub_None',
            'presenceGroupName': 'Standard Presence group',
            'callingAndCalledPartyInfoFormat': 'Deliver DN only in connected party'

View solution in original post

7 Replies 7

dstaudt
Cisco Employee
Cisco Employee

Per the schema, it looks like these are the valid options:

<xsd:enumeration value="Deliver DN only in connected party"/>
<xsd:enumeration value="Deliver URI only in connected party, if available"/>
<xsd:enumeration value="Deliver URI and DN in connected party, if available"/>

Not sure where DeliverOriginatingCalledPartyNumber is coming from...it isn't found in the schema anywhere..?  Was it seen via <getSipTrunk>?

import urllib3
from zeep import Client
from requests import Session
from requests.auth import HTTPBasicAuth
from zeep.transports import Transport

def setup_client(wsdl_url, cucm_address, username, password
    urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
    session = Session()
    session.verify = False
    session.auth = HTTPBasicAuth(username, password)
    transport = Transport(session=session)
    client = Client(wsdl_url, transport=transport)
    return client.create_service('{http://www.cisco.com/AXLAPIService/}AXLAPIBinding', 'https://{}/axl/'.format(cucm_address))

def create_partitions(service, partitions
    for partition in partitions:
        try:
            service.addRoutePartition({
                'name': partition,
                'description': partition,
                'isDefault': 'false'
            })
            print(f"Partition {partition} created successfully.")
        except Exception as e:
            print(f"Error creating partition {partition}: {e}")

def create_css(service, partitions
    for partition in partitions:
        try:
            service.addCss({
                'name': partition + '_CSS',
                'description': partition + ' Calling Search Space',
                'clause': partition,
                'members': {
                    'member': {
                        'routePartitionName': partition,
                        'index': '1'
                    }
                }
            })
            print(f"CSS {partition}_CSS created and associated with partition {partition}.")
        except Exception as e:
            print(f"Error creating CSS {partition}_CSS: {e}")

def create_srst_resources(service, srsts
    for srst in srsts:
        try:
            service.addSrst({
                'name': srst['name'],
                'description': srst['name'] + ' SRST Resource',
                'ipAddress': srst['ipAddress'],
                'port': '2000',
                'SipPort': '5060'
            })
            print(f"SRST Resource {srst['name']} created successfully.")
        except Exception as e:
            print(f"Error creating SRST Resource {srst['name']}: {e}")

def create_device_pools(service, device_pools
    for dp in device_pools:
        try:
            service.addDevicePool({
                'name': dp,
                'description': dp + ' Device Pool',
                'dateTimeSettingName': 'CMLocal',
                'regionName': 'Default',
                'callManagerGroupName': 'Default',
                'srstName': 'SRST_Resource_89'
            })
            print(f"Device Pool {dp} created successfully.")
        except Exception as e:
            print(f"Error creating device pool {dp}: {e}")

def create_sip_trunk_cube(service
    try:
        service.addSipTrunk({
            'name': 'cube',
            'description': 'SIP Trunk to CUBE',
            'product': 'SIP Trunk',
            'class': 'Trunk',
            'devicePoolName': 'school1',  # Reference the existing 'school1' device pool
            'protocol': 'SIP',
            'protocolSide': 'Network',
            'callingSearchSpaceName': 'pstninbound_CSS',
            'sipProfileName': 'Standard SIP Profile',
            'securityProfileName': 'Non Secure SIP Trunk Profile',
            'destinations': {
                'destination': {
                    'addressIpv4': 'xxx.xxx.x.xx',
                    'port': '5060',
                    'sortOrder': '1'
                }
            },
            'locationName': 'Hub_None',
            'presenceGroupName': 'Standard Presence group',
            'callingAndCalledPartyInfoFormat': 'DeliverOriginatingCalledPartyNumber'
        })
        print("SIP Trunk 'cube' created successfully.")
    except Exception as e:
        print(f"Error creating SIP Trunk 'cube': {e}")

if __name__ == '__main__':
    WSDL_URL = 'AXLAPI.wsdl'
    CUCM_ADDRESS = 'xxx.xxx.x.xx'
    USERNAME = 'XXX'
    PASSWORD = 'XXXX'

    service = setup_client(WSDL_URL, CUCM_ADDRESS, USERNAME, PASSWORD)

    partitions = ['internal', 'longdistance', 'international', 'pstninbound']
    create_partitions(service, partitions)
    create_css(service, partitions)

    srsts = [
        {'name': 'SRST_Resource_89', 'ipAddress': 'XXX.168.1.89'},
        {'name': 'SRST_Resource_99', 'ipAddress': 'XXX.168.1.99'}
    ]
    create_srst_resources(service, srsts)

    device_pools = ['school1', 'school2']  # Add 'school1' and other device pool names
    create_device_pools(service, device_pools)

    # ... [Other function calls...]

    # Create SIP Trunk 'cube' at the end
    create_sip_trunk_cube(service)

When I run the script everything works fin until adding the sip trunk i get this error 

Error creating SIP Trunk 'cube': ENUM for DeliverOriginatingCalledPartyNumber not found in TypeSIPIdentityBlend

Right...on this line:

'callingAndCalledPartyInfoFormat': 'DeliverOriginatingCalledPartyNumber'

you are providing an invalid value DeliverOriginatingCalledPartyNumber...where are you getting that value?

I thought  i read some place that goes there do you know at I need to add there 

just to clarify I was using chat-gpt to help with the code that was the recommendation  from aopen AI

kyrunner
Level 1
Level 1

I fixed it here was the final code for the sip trunk 

def create_sip_trunk_cube(service
    try:
        service.addSipTrunk({
            'name': 'cube',
            'description': 'SIP Trunk to CUBE',
            'product': 'SIP Trunk',
            'class': 'Trunk',
            'devicePoolName': 'school1',  # Reference the existing 'school1' device pool
            'protocol': 'SIP',
            'protocolSide': 'Network',
            'callingSearchSpaceName': 'pstninbound_CSS',
            'sipProfileName': 'Standard SIP Profile',
            'securityProfileName': 'Non Secure SIP Trunk Profile',
            'destinations': {
                'destination': {
                    'addressIpv4': 'xxx.xxx.xx.x',
                    'port': '5060',
                    'sortOrder': '1'
                }
            },
            'locationName': 'Hub_None',
            'presenceGroupName': 'Standard Presence group',
            'callingAndCalledPartyInfoFormat': 'Deliver DN only in connected party'