CUCM Provisioning (AXL)
via Provisioning Portal API

Up to this point, you have checked the portal's connectivity to the pod devices and initialized the global CUCM SOAP API Python classes shown below:

  • myAXL
  • myPAWSVersionService
  • mySXMLRisPort70Service
  • mySXMLControlCenterServicesService
  • mySXMLPerfMonService

In this section, you will implement the following CUCM AXL Provisioning API tasks utilizing the global classes in they provisioning portal:

  1. Get a phone device configuration details from CUCM
  2. Add a phone device to CUCM
  3. Update a phone device configuration on CUCM
  4. Delete a phone device from CUCM
  5. Get an end user's configuration details from CUCM
  6. Verification

Step 1 - Get Phone

As you have explored one of the portal's pre-built API routes located at http://dev1.pod6.col.lab:5000/api/v1/cucm/version with a GET method, you will now build a similar one that retrieves the phone device configuration details from the CUCM database. You will achieve this by leveraging the global CUCM SOAP API Python class myAXL that you instantiated earlier.

With the help of the CUCM SOAP API Python class myAXL you will send a getPhone thick AXL method and relay the response if successful.

All of the changes from now on will be in flaskr/api/v1/cucm.py
  1. In the VS Code tab, using the Explorer function, open up flaskr/api/v1/cucm.py
  2. In the cucm_phone_api() class, def get(self, device_name): method, locate the existing line raise Exception('Not implemented yet!!') remove it and replace it with the following highlighted lines.

    As you copy paste the following highlighted piece of code in to the VS Code open editor window, first off all always use the "COPY" button, you do not need to highlight the source code in the lab guide browser tab. After you have clicked the "COPY" button be sure to paste it starting from the beginning of the line. Either after you have deleted the entire line or after you have selected the whole line up to the beginning of the line. You may also triple click on the raise Exception('Not implemented yet!!') line as well. This ensures the pasted piece of code retains the correct indentation. For example:

    Note here you are calling from the myAXL class the get_phone() method while passing the device_name variable as an argument. The device_name variable is expected to be passed in to the portal API route as part of the URL. For example: "/cucm/phone/CSFPOD6USER1". This type of parameter is also referred as a path parameter.

  3. Save this file by going to Application Menu → File → Save or by simply Pressing Ctrl+S
  4. Ensure the cucm_phone_api() class, def get(self, device_name): method looks exactly as seen below.

Step 2 - Add Phone

Next let's work on adding a phone device to the CUCM database using the provisioning portal API. You will build upon the cucm_phone_api() class where you added a get method earlier.

You may recall from the REST APIs chapter, RESTful APIs map the HTTP verbs GET, POST, PUT, and DELETE to retrieve, create, modify, and delete an object that is being interacted with. In the Portal API, you will be building the POST method for the /cucm/phone/{device_name} portal API route, which will in turn execute a series of CUCM AXL API methods in order to achieve the task of adding the device based on your desired provisioning criteria.

The simple business logic is as follows:

  1. Get CUCM user details and retrieve the user's telephone number and current associated devices list
  2. Add the phone device to CUCM database
  3. Update the CUCM user, associating the directory number, newly added phone device and assign the user's primary extension

With the help of the CUCM SOAP API Python class myAXL you will utilize the following thick AXL methods:

and relay a final response if all AXL API requests are successful.

  1. In the VS Code tab, using the Explorer function, open up flaskr/api/v1/cucm.py
  2. In the cucm_phone_api() class, def post(self, device_name): method, locate the existing line raise Exception('Not implemented yet!!') remove it and replace it with the following highlighted lines.

    Try to step through a few of the lines of code above to understand what is happening. You should first of all understand that this code is being executed anytime the portal API receives a POST request to the /phone/<string:device_name> endpoint. The second highlighted line of code (line 17) shows the call to the get_user function. This is the function call that issues an AXL request to UCM and retrieves the user data. The next few lines are just parsing through the data that was returned to extract the phone number and associated devices.

    Next, you see a dictionary (set of key-value pairs) is created with all the information needed to describe a new phone to add. After this, you see a call to the add_phone function on line 57 which issues the AXL API call to add the phone. Finally, the last highlighted line shows the AXL API call to update_user which performs the task of updating the list of associated devices for the user.

  3. Save this file by going to Application Menu → File → Save or by simply Pressing Ctrl+S

Step 3 - Update Phone

Next let's work on updating an existing phone's configuration in the CUCM database via the portal API. You will build upon the cucm_phone_api() class where you have added the GET (retrieve) and POST (create) methods earlier. Now you will add the PUT method that will modify a given phone device name.

The simple business logic is as follows:

  1. Update the phone device configuration given API request arguments
  2. Apply the phone configuration and let it pick up the changes

With the help of the CUCM SOAP API Python class myAXL you will utilize the following thick AXL methods:

and relay a final response if all AXL API requests are successful.

  1. In the VS Code tab, using the Explorer function, open up flaskr/api/v1/cucm.py
  2. In the cucm_phone_api() class, def put(self, device_name): method, locate the existing line raise Exception('Not implemented yet!!') remove it and replace it with the following highlighted lines.

    You can see that this code is fairly straightforward. There is a variable created called phone_update_data that contains the data to be updated. In the name of simplicity, the update method you are creating here only allows you to update the calling search space and description of the device. This data is passed to the update_phone method which invokes the AXL API to update the phone.

  3. Save this file by going to application menu → File → save or by simply pressing Ctrl+S

Step 4 - Delete Phone

The final phone operation you will implent allows you to delete an existing phone device from the CUCM database via the Portal API. You will add the DELETE method to the cucm_phone_api() class that delete a given phone device based on the name provided.

With the help of the CUCM SOAP API Python class myAXL you will utilize the following thick AXL Method:

and relay a final response if all AXL API requests are successful.

  1. In the VS Code tab, using the Explorer function, open up flaskr/api/v1/cucm.py
  2. In the cucm_phone_api() class, def delete(self, device_name): method, locate the existing line raise Exception('Not implemented yet!!') remove it and replace it with the following highlighted lines.

    You can see that deleting an existing phone is easy. The one line you have added initiates the AXL API call to delete the phone, given the name of the device provided.

  3. Save this file by going to Application Menu → File → Save or by simply Pressing Ctrl+S

Step 5 - Get User

Next up let's work on retrieving an existing CUCM end user configuration detail from the CUCM database.

With the help of the CUCM SOAP API Python class myAXL you will utilize the following Thick AXL Method:

and relay a final response if all AXL API requests are successful.

  1. In the VS Code tab, using the Explorer function, open up flaskr/api/v1/cucm.py
  2. In the cucm_user_api() class, def get(self, userid): method, locate the existing line raise Exception('Not implemented yet!!') remove it and replace it with the following highlighted lines.

  3. Save this file by going to Application Menu → File → Save or by simply Pressing Ctrl+S

Step 6 - Verification

You have added a lot of new capabilities to the Provisioning Portal's APIs. Now it is time to make sure it all works as expected, again utilizing the Portal's RESTPlus/Swagger UI page.

  1. In VS Code, make sure flaskr/api/v1/cucm.py file is saved
  2. Restart the Flask app by clicking the green restart button from the controller: which you should always see along the top of the window, when Flask is running.
    Or, if Flask is not started at all, click the Debug button on the left side followed by the green start/play button next to Start LTRCOL-2574 Portal
  3. If the Terminal window at bottom right shows: * Running on http://10.0.106.40.40:5000/ (Press CTRL+C to quit), then the Flask app is running.
  4. Access the RESTPlus/Swagger UI page at http://dev1.pod6.col.lab:5000/api/v1/
  5. Expand the cucm section.
  6. Perform the following individual checks:
    1. Get a Phone Device Configuration Details from CUCM
      1. Click the GET /cucm/phone/{device_name} operation.
      2. At right, click Try it out.
      3. For the device_name Parameter, enter CSFPOD6UCMUSER
      4. In the expanded section, click Execute.
      5. Scroll down and examine the server response. You should note a server response code of 200 and a response body with the details of the Phone Device Configuration. Here is a sample response body:
            {
                "message": "Phone Data Retrieved Successfully",
                "phone_data": {
                    "AllowPresentationSharingUsingBfcp": null,
                    "aarNeighborhoodName": {
                    "_value_1": null,
                    "uuid": null
                    },
                    "activationIDStatus": null,
                    ...
                    "automatedAlternateRoutingCssName": {
                    "_value_1": null,
                    "uuid": null
                    },
                    ...
                    "description": "Cisco Live LTRCOL-2574 - pod6ucmuser",
                    ...
                    "name": "CSFPOD6UCMUSER",
                    ...
                }
            }
                                
    2. Add a Phone Device to CUCM
      1. Click the POST /cucm/phone/{device_name} operation.
      2. At right, click Try it out.
      3. For the description Parameter, enter Cisco Live LTRCOL-2574 - pod6UCMUSER Cisco Webex Desk Pro
      4. For the phonetype Parameter, enter Cisco Webex Desk Pro
      5. For the ownerUserName Parameter, enter pod6ucmuser
      6. For the calleridname Parameter, enter Pod6 UCM User
      7. For the device_name Parameter, enter SEP00A0C914C829
      8. In the expanded section, click Execute.
      9. Scroll down and examine the server response. You should note a server response code of 200 and a response body with the uuids of the newly added phone and the associated user you just updated. Here is a sample response body:
            {
                "message": "Phone Added Successfully",
                "phone_uuid": "{34103D82-4947-7DB7-E2BC-CB2043EEEF74}",
                "success": true,
                "user_uuid": "{9E35D561-735E-2357-C4EE-18BBBDA8CB5B}"
            }
                                
    3. Update a Phone Device Configuration on CUCM
      1. Click the PUT /cucm/phone/{device_name} operation.
      2. At right, click Try it out.
      3. For the callingSearchSpaceName Parameter, enter Unrestricted_CSS
      4. For the device_name Parameter, enter SEP00A0C914C829
      5. In the expanded section, click Execute.
      6. Scroll down and examine the server response. You should note a server response code of 200 and a response body with the uuid phone device you just updated. Here is a sample response body:
            {
                "message": "Phone Configuration Updated & Applied Successfully",
                "success": true,
                "uuid": "{34103D82-4947-7DB7-E2BC-CB2043EEEF74}"
            }
                                
    4. Delete a Phone Device from CUCM
      1. Click the DELETE /cucm/phone/{device_name} operation.
      2. At right, click Try it out.
      3. For the device_name Parameter, enter SEP00A0C914C829
      4. In the expanded section, click Execute.
      5. Scroll down and examine the server response. You should note a server response code of 200 and a response body with the uuid of the phone you have just deleted. Here is a sample response body:
            {
                "message": "Phone Successfully Deleted",
                "success": true,
                "uuid": "{34103D82-4947-7DB7-E2BC-CB2043EEEF74}"
            }
                                
    5. Delete another Phone Device from CUCM (CSFPOD6UCMUSER)
      You need to delete this CSF device that you added earlier in the CUCM Administrative XML (AXL) section via the addPhone AXL request. Don't worry, you will be re-adding this device via the finished Portal soon.
      1. Click the DELETE /cucm/phone/{device_name} operation.
      2. At right, click Try it out.
      3. For the device_name Parameter, enter CSFPOD6UCMUSER
      4. In the expanded section, click Execute.
      5. Scroll Down and Examine the Server response. You should note a Server response code of 200 and a response body with the uuid of the phone you have just deleted. Here is a sample response body:
            {
                "message": "Phone Successfully Deleted",
                "success": true,
                "uuid": "{34103D82-4947-7DB7-R2D2-WOK043EFFF77}"
            }
                                
    6. Get an EndUser Configuration from CUCM
      1. Click the GET /cucm/user/{userid} operation.
      2. At right, click Try it out.
      3. For the userid Parameter, enter pod6ucmuser
      4. In the expanded section, click Execute.
      5. Scroll Down and Examine the Server response. You should note a Server response code of 200 and a response body with the uuid of the phone you have just deleted. Here is a sample response body:
            {
                "message": "User Data Retrieved Successfully",
                "success": true,
                "user_data": {
                    "associatedCapfProfiles": null,
                    "associatedDevices": {
                    "device": [
                        "CSFPOD6UCMUSER"
                    ]
                    },
                    "associatedGroups": {
                    "userGroup": [
                        {
                        "name": "Standard CTI Enabled",
                        "userRoles": {
                            "userRole": [
                            "Standard CTI Enabled"
                            ]
                        }
                        },
                        {
                        "name": "Standard CCM End Users",
                        "userRoles": {
                            "userRole": [
                            "Standard CCM End Users",
                            "Standard CCMUSER Administration"
                            ]
                        }
                        }
                    ]
                    }
                    ...
                    "userid": "pod6ucmuser",
                    ...
                }
            }
                                

Congratulations! You have added some core CUCM provisioning capabilities to the Portal APIs that allows you to manage phone devices. Let's add some CUCM Serviceability capabilities to the Portal APIs that can help you monitor CUCM.