Interacting with the Collaboration Endpoint Api using Python – Hiding The Webex Join Button

By 18th February 2020Cisco, Collaboration Endpoint Api

Version 9.10 of Cisco Collaboration Endpoint (CE) software introduces the Webex Join button to the touch ten control panel, however if this is not something that you have a use for then depending on your CUCM version you may need to login to each endpoint to remove the button. The following code demonstrates how you can use the Collaboration Endpoint Api to hide the Webex Join button.

First we open, read, split and iterate through our input file of endpoints, passing each ip address to the “check_version” function inside a try & accept clause, this is to catch exceptions from connection attempts timing out for non registered and mra registered devices. The function obtains the current codec version with a “getxml” request and returns True if we have a device running “ce9.10.0.50f5888d087” (matching our deployed version where the Webex join button is enabled by default).

For matching devices we call “disable_webex_button”, again passing in the ip. This function builds and posts the appropriate XML message changing the “JoinWebex” value to “hidden” from the default “auto”.

Full Code
 
  1. __author__ = "Mitch Dawson"
  2. __contact__ = "info@ucdevops.com"
  3. __copyright__ = "Copyright (C) 2020 Ucdevops All Rights Reserved"
  4. __license__ = "GPLv3"
  5. """
  6. This program is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program. If not, see http://www.gnu.org/licenses.
  16. """
  17. import requests
  18. requests.packages.urllib3.disable_warnings()
  19. import xmltodict
  20. # Define the Api user credential
  21. user = "apiuser"
  22. # Define the Api Password Credential
  23. pwd = "apipass"
  24. # Define the url for the system version get request
  25. get_version_url = "/getxml?location=/Status/SystemUnit/SoftwareVersion"
  26. # Define the url for the put
  27. put_xml = "/putxml"
  28. ## Define the required Software Version, the webex button was added in CE9.10
  29. version = "ce9.10.0.50f5888d087"
  30. # HTTP Content Header
  31. headers = {"Content-Type": "text/xml"}
  32. # Disable Webex Button Dict Structure
  33. dwb = {
  34. "Configuration": {
  35. "UserInterface": {
  36. "Features": {
  37. "Call": {
  38. "JoinWebex": "Hidden"
  39. }
  40. }
  41. }
  42. }
  43. }
  44. # Define the function to check the VC system version
  45. def check_version(vc):
  46. # Build the url
  47. url = "https://" + vc + get_version_url
  48. # Make the GET request
  49. r = requests.get(
  50. # Build the url
  51. url=url,
  52. # Add the Content Headers
  53. headers=headers,
  54. # Disable certificate validation
  55. verify=False,
  56. # Provide the Basic auth credentials
  57. auth=(user, pwd)
  58. )
  59. # Check the status for 200 OK
  60. if r.status_code != 200:
  61. return False
  62. # Convert the response to xml
  63. x = xmltodict.parse(r.text)
  64. # Break out the version
  65. v = x["EmptyResult"]["@version"]
  66. # Check the version we require
  67. if v != version:
  68. return False
  69. # Finally return True if we have matched the required version
  70. return True
  71. def disable_webex_button(vc):
  72. # Build the url
  73. url = "https://" + vc + put_xml
  74. # Make the POST request
  75. r = requests.post(
  76. # Build the url
  77. url=url,
  78. # Add the Content Headers
  79. headers=headers,
  80. # Disable certificate validation
  81. verify=False,
  82. # Provide the Basic auth credentials
  83. auth=(user, pwd),
  84. # Parse the dictionary structure and add the generated XML Body to the request
  85. data=xmltodict.unparse(dwb)
  86. )
  87. # Print the output
  88. print(r.text)
  89. def main():
  90. # Open the input file
  91. vc_hosts = open("vc.text", "r").read().split("\n")
  92. # Iterate through our Hosts
  93. for vc in vc_hosts:
  94. print("#" * 100)
  95. # Create a Try & Accept Loop To Catch non responsive devices
  96. try:
  97. print("Checking VC IP '{}'".format(vc))
  98. if not check_version(vc):
  99. print("Unsupported version, skipping device")
  100. continue
  101. except Exception as e:
  102. print(str(e))
  103. pass
  104. else:
  105. # When we have a compatible session
  106. print("Attempting to Disable Webex Join Button")
  107. disable_webex_button(vc)
  108. if __name__ == "__main__":
  109. main()
Mitch

Author Mitch

I am an independent IT Consultant with specialities in Software Development, Enterprise Unified Communication, Network and Security platforms. In addition to my day to day work, I develop bespoke applications and I hope that through ucdevops.com I can build relationships with clients, business partners and fellow engineers by providing solutions to complex problems through the use of programming.

More posts by Mitch
"