cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements
Walkthrough Wednesdays
218
Views
10
Helpful
6
Replies
erichumier3186
Beginner

Update MOH audio on CUCM v11

Hi,

I have a Central and unique CUCM Server that is the phone system for 22 offices in France (by 22 Switch gateway).
I have to create a little program who update the MOH Audio separately for the 22 offices (22 differents audio file).
I have to update closing and opening hours too.
I can use the API with one the possible language. I already started to consult AXL help (https://developer.cisco.com/docs/axl-schema-reference/) but is it possible to have a little "boost" with an example of code to update Audio MOH for example please (whatever the language)?

Thank you

6 REPLIES 6
Anthony Holloway
Cisco Employee

Unfortunately, there is no method to upload a new audio file via AXL.

I did write a bulk MOH uploader which I've only ever used on a v11.5 system, so it should work for you.

 

#!/usr/bin/env python3
import sys
import requests
from bs4 import BeautifulSoup

# Ignore SSL Warnings
requests.packages.urllib3.disable_warnings()

# CallManager servers to upload music to
moh_hosts = [
	"cucmpub.company.com",
	"cucmsub1.company.com",
	"cucmsub2.company.com",
]

# CallManager credentials
moh_user = "appadministrator"
moh_pass = "P@ssw0rd!"

# Get the music files as command line arguments
moh_files = sys.argv[1:]

if len(moh_files) <= 0:
	print("No files specified")
	sys.exit(1)
	
# I hope you specified real music file names, because we're about to upload them

for moh_host in moh_hosts:

	url_base = f"https://{moh_host}/ccmadmin/"
	url_login = f"{url_base}j_security_check"
	url_upload = f"{url_base}mohAudioFileUpload.do?type=mohAudioManagement"

	# Allows us to keep track of our login session
	print(f"\nLogging in to {moh_host}...",)
	connection = requests.Session()

	# Start a new session by simply accessing a page on the server
	resp = connection.get(url_base, verify = False)

	# Our login form data
	form_data = {
		"appNav": "ccmadmin",
		"j_username": moh_user,
		"j_password": moh_pass
	}

	# Our login submission to the server
	resp = connection.post(url_login, verify = False, data = form_data)
	print("Success!\n")
	
	for moh_file in moh_files:

		# We need to grab the token the server gives us, so we can pass it back upon upload
		# print("Grabbing a new token...",)
		soup = BeautifulSoup(connection.get(url_upload, verify = False).content, 'html.parser')

		# It's a hidden input element on the upload form with the name of "token"
		token = soup.find("input", {"name": "token"}).get("value")
		# print(f"Found! [{token}]\n")

		# Our upload form submission data
		payload = {
			"struts.token.name": (None, "token"),
			"token": (None, token),
			"file": (moh_file, open(moh_file, "rb"), "audio/wav"),
		}

		# Our upload submission to the server
		print(f"Uploading file: {moh_file}...",)
		resp = connection.post(url_upload, verify = False, files = payload)
		print("Success!\n")

print("Done!")

 

I simply wrote it to be ran from the command line like so:

python moh-uploader.py music1.wav music2.wav musicN.wav

From there, you could use the AXL API to swap out the audio source file each of your moh audio sources are referencing.  I did not need to do that, so no code to share with you there.  But, hopefully this will get you over the hurdle of AXL not supporting this feature, and then from here it's smooth sailing with your UpdateMohAudioSourceReq!

Thank you, It's kind of you.

I will share this proposal with developpers.

Also, we have to manage week time profil office by office.

Hello,

Could i have more informations please?

I think to switch Audio MOH Source, one function must be the good one but which it ?

Same question for update hour day week profil please?

Finally, as you know, our CUCM "manage" 22 offices. And i dont't know the scture of coding informations for identified an Office precisely in AXL function. I hope a parameter exist for that but wich one?

Sorry for this question but we are in a cul de sac?

 Thank you

I'm sorry but I don't understand you.  Could you please rephrase your questions?

Hi,

ok i rephrase :

"

As i said i ask for a little bit more help please.

I have to developpe a software who change music on hold and hourly profile of the week for every entity (22 offices) managed by the CUCM server.

After consulting AXL help, I understand that there must be a function dedicated to the selection of an already loaded sound file. There is also probably a function to change the time profile of the week. Could you indicate me these functions and also indicate to me how one finds and selects the good entity (office) in these functions?

Maybe the functions I'm looking for are XMOHAudioSourceId or UpdateFixedMohAudioSourceReq for MOH and i don't find for define open/close hour (Toggles between waiting message and answering machine) 

(source : https://developer.cisco.com/docs/axl-schema-reference/)

the ideal would be to have sample scripts please, whatever the code language.

 

We are not Cisco CUCM experts but luckily we have to make a very simple program.

"

Best regards

Eric

Have you considered a local MoH source at each site that you can manage?  https://www.barix.com has some options that are affordable and may make this easier.  You just set the multicast for each location and then setup the device to broadcast.  

Content for Community-Ad

Spotlight Awards 2021