Cisco CUCM – AXL API requests using Python

Hey guys,

Following my post about the overview of Cisco CUCM – SOAP (read it HERE), I’m going to show you now how to send some basic requests using Python.

To be able to do that, you will need to have:

  • Python installed (download it here)
  • AXLSQLToolkit
  • Python Libraries (Zeep, urllib3 , requests – installed via PIP)

After installing Python and its libraries, let’s go to the codes!

To run my codes, I use PyCharm….but you can use any other software of your preference.

Firstly, you have to declare your libraries:
*Code will be passed at the end of the article Smile

image

Now you have to enter your CUCM information, such as IP, username and password.
We are going to use ZEEP to create SOAP requests. In case of any fault, Zeep will show what SOAP envelope that was sent and the response from CUCM AXL.
If you’re not disabling SSL verification, host should be the FQDN of the server rather than IP.


image

To start with a simple request, I’ll show you how to list Phones.
Have in hands the  Cisco DevNet AXL Schema Reference. It will help you to understand each request, which argument you must send as a searchCriteria and which arguments you must expect as returnedTags.
Only declared arguments in the returnedTags will be displayed. The rest will be showed as none.

For example, I want to list a phone, based on the Device Name, and want to have the arguments namedescription, model and device pool being returned to me.
The code will look like this:

image

The result will like this:

{
     ‘return’: {
         ‘phone’: [
             {
                 ‘name’: ‘SEP0004F2F01F1A’,
                 ‘description’: ‘Meeting Room’,
                 ‘product’
: None,
                 ‘model’: ‘Cisco 7937’,
                 ‘class’: None,
                 ‘protocol’: None,
                 ‘protocolSide’: None,
                 ‘callingSearchSpaceName’: None,
                 ‘devicePoolName’: {
                     ‘_value_1’: ‘BE_KNO_DP’,
                     ‘uuid’: ‘{960A36D4-C7ED-49B8-A53C-B188BE30635A}’
                 },
                 ‘commonDeviceConfigName’: None,
                 ‘commonPhoneConfigName’: None,
                 ‘networkLocation’: None,
                 ‘locationName’: None,
                 ‘mediaResourceListName’: None,
                 ‘networkHoldMohAudioSourceId’: None,
                 ‘userHoldMohAudioSourceId’: None,
                 ‘automatedAlternateRoutingCssName’: None,
                 ‘aarNeighborhoodName’: None,
                 ‘loadInformation’: None,
                 ‘traceFlag’: None,
                 ‘mlppIndicationStatus’: None,
                 ‘preemption’: None,
                 ‘useTrustedRelayPoint’: None,
                 ‘retryVideoCallAsAudio’: None,
                 ‘securityProfileName’: None,
                 ‘sipProfileName’: None,
                 ‘cgpnTransformationCssName’: None,
                 ‘useDevicePoolCgpnTransformCss’: None,
                 ‘geoLocationName’: None,
                 ‘geoLocationFilterName’: None,
                 ‘sendGeoLocation’: None,
                 ‘numberOfButtons’: None,
                 ‘phoneTemplateName’: None,
                 ‘primaryPhoneName’: None,
                 ‘ringSettingIdleBlfAudibleAlert’: None,
                 ‘ringSettingBusyBlfAudibleAlert’: None,
                 ‘userLocale’: None,
                 ‘networkLocale’: None,
                 ‘idleTimeout’: None,
                 ‘authenticationUrl’: None,
                 ‘directoryUrl’: None,
                 ‘idleUrl’: None,
                 ‘informationUrl’: None,
                 ‘messagesUrl’: None,
                 ‘proxyServerUrl’: None,
                 ‘servicesUrl’: None,
                 ‘softkeyTemplateName’: None,
                 ‘loginUserId’: None,
                 ‘defaultProfileName’: None,
                 ‘enableExtensionMobility’: None,
                 ‘currentProfileName’: None,
                 ‘loginTime’: None,
                 ‘loginDuration’: None,
                 ‘currentConfig’: None,
                 ‘singleButtonBarge’: None,
                 ‘joinAcrossLines’: None,
                 ‘builtInBridgeStatus’: None,
                 ‘callInfoPrivacyStatus’: None,
                 ‘hlogStatus’: None,
                 ‘ownerUserName’: None,
                 ‘ignorePresentationIndicators’: None,
                 ‘packetCaptureMode’: None,
                 ‘packetCaptureDuration’: None,
                 ‘subscribeCallingSearchSpaceName’: None,
                 ‘rerouteCallingSearchSpaceName’: None,
                 ‘allowCtiControlFlag’: None,
                 ‘presenceGroupName’: None,
                 ‘unattendedPort’: None,
                 ‘requireDtmfReception’: None,
                 ‘rfc2833Disabled’: None,
                 ‘certificateOperation’: None,
                 ‘authenticationMode’: None,
                 ‘keySize’: None,
                 ‘keyOrder’: None,
                 ‘ecKeySize’: None,
                 ‘authenticationString’: None,
                 ‘certificateStatus’: None,
                 ‘upgradeFinishTime’: None,
                 ‘deviceMobilityMode’: None,
                 ‘roamingDevicePoolName’: None,
                 ‘remoteDevice’: None,
                 ‘dndOption’: None,
                 ‘dndRingSetting’: None,
                 ‘dndStatus’: None,
                 ‘isActive’: None,
                 ‘isDualMode’: None,
                 ‘mobilityUserIdName’: None,
                 ‘phoneSuite’: None,
                 ‘phoneServiceDisplay’: None,
                 ‘isProtected’: None,
                 ‘mtpRequired’: None,
                 ‘mtpPreferedCodec’: None,
                 ‘dialRulesName’: None,
                 ‘sshUserId’: None,
                 ‘digestUser’: None,
                 ‘outboundCallRollover’: None,
                 ‘hotlineDevice’: None,
                 ‘secureInformationUrl’: None,
                 ‘secureDirectoryUrl’: None,
                 ‘secureMessageUrl’: None,
                 ‘secureServicesUrl’: None,
                 ‘secureAuthenticationUrl’: None,
                 ‘secureIdleUrl’: None,
                 ‘alwaysUsePrimeLine’: None,
                 ‘alwaysUsePrimeLineForVoiceMessage’: None,
                 ‘featureControlPolicy’: None,
                 ‘deviceTrustMode’: None,
                 ‘earlyOfferSupportForVoiceCall’: None,
                 ‘requireThirdPartyRegistration’: None,
                 ‘blockIncomingCallsWhenRoaming’: None,
                 ‘homeNetworkId’: None,
                 ‘AllowPresentationSharingUsingBfcp’: None,
                 ‘confidentialAccess’: None,
                 ‘requireOffPremiseLocation’: None,
                 ‘allowiXApplicableMedia’: None,
                 ‘enableCallRoutingToRdWhenNoneIsActive’: None,
                 ‘ctiid’: None,
                 ‘uuid’: ‘{81F827A6-3B58-F7F0-39BF-DBA51E81B606}’
             }
         ]
     },
     ‘sequence’: None
}

As I mentioned, if you don’t declare you want to have your argument being returned, it will be displayed as None.

Right. Now, you have to use your Python skills to take any action based on your output.
For example, if you want to isolate the returned tags to save them in a variable, you can use a For Loop to do something like that:

image
And the result will be this:

image

Now, you can use the Cisco DevNet AXL Schema Reference to explore all possibilities you have.

You can, for example, add new phones, new lines…

Adding Lines

According to the Schema, you don’t have Search Criteria or Returned Tags in the addLine request.
So, the code you be like this:

image

This is the line we’ve just added:

image

As I always say…now, sky is the limit!
You can do whatever you want by following the Schema….like add/delete/list Phones, lines, Device Pool, Device Profile, etc, etc, etc…

Hope you liked it Smile

See you!

Whole Code

from zeep import Client
from zeep.cache import SqliteCache
from zeep.transports import Transport
from zeep.exceptions import Fault
from zeep.plugins import HistoryPlugin
from requests import Session
from requests.auth import HTTPBasicAuth
from urllib3 import disable_warnings
from urllib3.exceptions import InsecureRequestWarning
from lxml import etree

disable_warnings(InsecureRequestWarning)

username = ‘admin’
password = ‘Cisco123’

hostIP = ‘192.168.1.10’
location = ‘https://192.168.1.10:8443/axl/’.format(host=hostIP)
binding = “{http://www.cisco.com/AXLAPIService/}AXLAPIBinding”
wsdl = ‘file://C:/Users/user123/AppData/Local/Programs/Python/Python38-32/axlsqltoolkit/schema/11.5/AXLAPI.wsdl’

session = Session()
session.verify = False
session.auth = HTTPBasicAuth(username, password)

transport = Transport(cache=SqliteCache(), session=session, timeout=20)
history = HistoryPlugin()
client = Client(wsdl=wsdl, transport=transport, plugins=[history])
service = client.create_service(binding, location)

def show_history():
     for hist in [history.last_sent, history.last_received]:
         print(etree.tostring(hist[“envelope”], encoding=”unicode”, pretty_print=True))

try:
     resp = service.listPhone(searchCriteria={‘name’: ‘SEP0004F2F01F1A’},
                              returnedTags={‘name’: ”, ‘description’: ”,
                                            ‘model’: ”, ‘devicePoolName’: ”})
     print(resp)
except Fault:
     show_history()

phone_list = resp[‘return’].phone
for phone in phone_list:
     print(phone[‘name’])
     print(phone[‘description’])
     print(phone[‘model’])
     print(phone[‘devicePoolName’]._value_1)

try:
     resp = service.addLine(line={‘pattern’: ‘707080’, ‘usage’: ‘Device’,
                                  ‘description’: ‘Test’, ‘routePartitionName’: ‘ONCLUSTER’})
     print(resp)
except Fault:
     show_history()

Media Resources on CUCM (Conference Bridge and Transcoder)

Hi people,

In this post I’ll cover a little bit of resources on CUCM, more specifically Transcoding and Conference Bridge.

The requirements to have them configured on your Voice Gateway, and consequently being used on CUCM, are DSPs.
DSPs reside either directly on a voice network module, on PVDM2s that are installed in a voice network module or on PVDMs that are installed directly onto the motherboard, such as on the Cisco 2800 and 3800 series voice gateway routers.

Having your DSP, let’s configure this bad boy in your Voice Gateway.

  • Configuring SCCP

!— This sccp ccm command adds CallManager server(s) !— to the list of available servers to which the voice gateway can register.
Gateway(config)#sccp ccm 192.168.252.18 identifier 18 priority 1 version 4.1
Gateway(config)#sccp ccm 192.168.198.10 identifier 5 priority 2 version 4.1
Gateway(config)#sccp ccm 192.168.198.11 identifier 4 priority 3 version 4.1
Gateway(config)#sccp ccm 192.168.198.12 identifier 11 priority 4 version 4.1

!— Selects the local interface that SCCP applications !— use to register with CUCM.
Gateway(config)#sccp local loopback 1

!— Enables SCCP and brings it up administratively.
Gateway(config)#sccp Gateway(config)#exit

  • Configuring DSP Farm for Transcoding


!— The dsp services dspfarm command enables DSP farm services for the voice card.

Gateway(config)#voice-card 0
Gateway(config-voicecard)#dsp services dspfarm


!— The dspfarm profile 111 transcode command enters the !— DSP farm profile configuration mode !— to define a profile for DSP farm services. !— For this profile, a transcode profile is created.

Gateway(config-voicecard)#exit
Gateway(config)#dspfarm profile 111 transcode


!— Specifies the codecs supported by a DSP farm profile.

Gateway(config-dspfarm-profile)#codec ?
   g711alaw      G.711 A Law 64000 bps
   g711ulaw      G.711 u Law 64000 bps
   g729abr8      G.729ab 8000 bps
   g729ar8       G.729a 8000 bps
   g729br8       G.729b 8000 bps
   g729r8        G.729 8000 bps
   pass-through  Stream Pass Through

!— Specifies the maximum number of sessions that are !— supported by the profile. !— Number is determined by the available registered !— DSP resources.
Gateway(config-dspfarm-profile)#maximum sessions 20

!— The associate application sccp command associates the SCCP protocol !— to the DSP farm profile.
Gateway(config-dspfarm-profile)#associate application sccp

!— Enables the profile, allocates !— DSP farm resources, and associates the application.
Gateway(config-dspfarm-profile)#no shutdown
Gateway(config-dspfarm-profile)#exit
Gateway(config)#gateway

!— Sets the Real-Time Transport !— Protocol (RTP) timeout interval to clear hanging connections. !— Seconds range is 180 to 1800. The default is 1200.
Gateway(config-gateway)#timer receive-rtp 600

  • Creating Call Manager group

Gateway>enable
Gateway#configure terminal
Gateway(config)#sccp ccm group 111

!— Adds a Cisco Unified CallManager server to the Cisco !— Unified CallManager group and establishes its priority within the group.
Gateway(config-sccp-ccm)#associate ccm 18 priority 1
Gateway(config-sccp-ccm)#associate ccm 5 priority 2
Gateway(config-sccp-ccm)#associate ccm 4 priority 3
Gateway(config-sccp-ccm)#associate ccm 11 priority 4

!— Associates a DSP farm profile to the Cisco Unified CallManager group. !— The device-name must match the device name configured in Cisco Unified CallManager.
Gateway(config-sccp-ccm)#associate profile 111 register DE_XCODE_01


!— Binds an interface to the Cisco Unified CallManager group.

Gateway(config-sccp-ccm)#bind interface loopback 1
Gateway(config-sccp-ccm)end

Now, let’s do the same for Conferencing Bridge

The process is purely the same, so I’ll just put the commands here:

Gateway>enable
Gateway#configure terminal
Gateway(config)#voice-card 0
Gateway(config-voicecard)#dsp services dspfarm
Gateway(config-voicecard)#exit
Gateway(config)#dspfarm profile 999 conference
Gateway(config-dspfarm-profile)#description conference profile 999
Gateway(config-dspfarm-profile)#codec ?
   g711alaw      G.711 A Law 64000 bps
   g711ulaw      G.711 u Law 64000 bps
   g729abr8      G.729ab 8000 bps
   g729ar8       G.729a 8000 bps
   g729br8       G.729b 8000 bps
   g729r8        G.729 8000 bps
   pass-through  Stream Pass Through

Gateway(config-dspfarm-profile)#maximum sessions 4
Gateway(config-dspfarm-profile)#associate application sccp
Gateway(config-dspfarm-profile)#no shutdown
Gateway(config-dspfarm-profile)#exit
Gateway(config)#gateway
Gateway(config-gateway)#timer receive-rtp 600
Gateway(config-gateway)#exit

Gateway>enable
Gateway#configure terminal
Gateway(config)#sccp ccm group 999
Gateway(config-sccp-ccm)#associate ccm 18 priority 1
Gateway(config-sccp-ccm)#associate ccm 5 priority 2
Gateway(config-sccp-ccm)#associate ccm 4 priority 3
Gateway(config-sccp-ccm)#associate ccm 11 priority 4
Gateway(config-sccp-ccm)#associate profile 999 register 00C88B514BDF
Gateway(config-sccp-ccm)#bind interface loopback 1

Gateway(config-sccp-ccm)end

Time now to add them to our Unified Communications Manager

  • Transcoder

On CUCM, go to Media Resources >> Transcoder >> Add new

Choose Cisco IOS Enhanced Media Termination Point for the Transcoder Type, and fill the rest with your Device Pool,  and for the Device Name, use the name you added on the Gateway:

image

Save and Reset it. You must see it as registered

  • Conference Bridge

On CUCM, go to Media Resources >> Conference Bridge >> Add new

Choose Cisco Conference Bridge Hardware for the Conference Bridge Type, and fill the rest with your Device Pool, Location, and for the Mac Address, use the name you added on the Gateway:

image

Save and Reset it. You must see it as registered

Now, added them both in a Media Resource Group, and then add this group to a Media Resource Group List.

Job done!!

Cheers Smile

Cisco Single Number Reach

Hey guys!
Here is Bruno, and I’ll be in charge of the Cisco side of this Blog, more specifically, Collaboration.

For my opening post, I’d like to talk about a feature on CUCM that, due all this pandemic situation, is being largely implemented.


Cisco Single Number Reach (SNR), or known as Mobile Connect, is a feature which allows users to answer incoming calls to their extension on either their desktop IP phone or at a remote destination, such as a mobile phone. 

As many companies had to send employees to work from home, SNR becomes really useful to cover some gaps you may have in your infrastructure.

To give you some practical examples, there were 2 situations where I configured SRN to save user’s life.
In the first, a small company didn’t have a good infra to send users to home (lack of bandwidth, poor VPN) and in the second, users were vendors and firewalls didn’t allow them to have Jabber connected to VPN.
In both situations, users had to receive calls from a queue on UCCX.
I came up with SNR for both cases, so users could work from home, and even though they weren’t using any softphone, they could answer calls coming from they extension.

Although Cisco does not mention in its Documentation, I configured and tested SNR with UCCX with success  Smile

So, how does this work?

When a call comes in to your Extension Number,  SNR will reroute the call not only to a DN, but also to your remote number, that can be your mobile phone. If needed, you can configure rerouting to a group of remote numbers that belong to an employee.
In other words, SNR provides you a functionality similar to Shared Line. The difference is that in this case a shared line is organized between an office phone and some remote device that isn’t necessary in a cluster, not between the phones within a cluster.

image
Said that, let’s get down to business!

What do you need to configure?

Configuring End User

Configuring Remote Destination Profile

Configuring Remote Destination

Configuring End User

In the End User page, make sure the Device is already associated in the Controlled Devices and its Line is assigned as Primary Line

imageimage

Check the Enable Mobility check box. You can also, modify the Maximum Wait Time for Desk Pickup and Remote Destination Limit if required. Moreover, the default values can be seen in the image.

image

Configuring Remote Destination Profile

Time to create a new Remote Destination Profile.
On CUCM, go to Device > Device Settings > Remote Destination Profile > Add new

You can choose any name, associate your user ID, give a calling search space and a rerouting CSS.
CUCM attempts to reach the remote destination through the Rerouting calling search Space.

image

Click Save, now you can see an option to add a new Directory number (DN) .

Click Add a new DN to navigate to directory number configuration, where you need to specify the directory number of the desk phone with which you need to associate the RDP and then click Save.

imageimage

Configuring Remote Destination

Time to configure the Remote Destination.
Specify the Destination number, as this is the number for your Remote destination.
Ensure that the check box, Enable Unified Mobility features, Enable Single Number Reach, Enable Move to Mobile is checked.

Single Number Reach Voicemail Policy provides two options: Timer control and User Control, of which the former one is default.

Under the section Timer information, you can specify the amount of delay before which the Remote Destination should ring.
In case if the Remote Destination is required to ring immediately, you should set the Wait as 0.
It is also important to calibrate the time in which the service provider of the remote destination sends the call to the voice-mail of the remote destination. The Stop ringing this phone after value should be set lesser then that to ensure that call does not go to the voicemail of the cell phone. This time value is specified against Stop ringing this phone after.

image

If the SNR voicemail policy is configured for User Control, timer information changes as shown in the image:

In case the SNR configuration needs to be restricted based on time and day then these options are modified as required. If no restriction is needed to be applied then Ring Schedule should be set to All the time and When receiving a call  during the above ring schedule should be set to Always ring this destination.
After you complete the configuration of remote destination, click Save.

IMPORTANT STEP!!!
Check the checkbox, which is next to the line and click Save.

image

That’s all guys!
I hope this post will help you out!

See ya!

Bruno Falco