Showing results for 
Search instead for 
Did you mean: 

Python Script for Automatic/Scheduled Reboots of UC Cluster


Hello Experts,


I have a particular, but I think possible request! Our company's current UC System Engineer(s) has to spend over an hour, sometimes 2 hours rebooting our UC Cluster consisting of 10 servers. We typically like to do this every 30-50 days. Firstly, is it possible to automate this process via a Python script? Secondly, if it is possible, can anyone provide how-to's for the scripting, references, quick gotchas, real-world experience, etc... in doing so? The business use case for this is to automate this process so that our engineers can run the script, walk away and come back to check on the status every so often instead of having to sit and watch, and click through all the areas to reboot each server. Please let me know if this is the wrong area to post this discussion, and kindly point me in the right direction!

10,000-foot Overview of the UC Environment:

CUCM consisting of 1 Publisher and 3 Subscribers.

CIMP consisting of 1 Publisher and 1 Subscriber.

UCCX consisting of 1 Publisher and 1 Subscriber.

CUCX consisting of 1 Publisher and 1 Subscriber. 


10 Servers in all. They're all Virtual Appliances hosted on B6000M-series servers acting as our ESXi hosts.

Cisco Employee

Certainly PAWS would be the API to take a look at for this use-case:

There is  small sample app, however it is Java based...perhaps it could serve as  template:

As PAWS is a SOAP API (XML over HTTP), you might consider the Zeep project for Python SOAP:

there is a new Python sample for the AXL SOAP API (not too dissimilar from PAWS) using Zeep that you might be able to adapt:


Hello dstaudt,

Thank you for your reply. I am very, very green at Python programming and understand this may be a little too advanced to try for my first business-case script. Thank you for the links and the information. I will look into these and try to make some understanding of them!



DOing research on the PAWS API installation and I have some questions. Is this a free installation? Is there licensing involved? Does this need to be a centralized server as I understand it contacts a SOAP server, or does this need to be installed on all of the UC B6000 series servers that the Cisco UC Applications are installed on? 

Also, according to  --- this document says that the installation formats the drives and will overwrite the data on that server so installing this on the existing infrastructure would be a showstopper. 




It looks like PAWS-M is a standalone GUI appliance/app that uses the PAWS API under the covers to perform management tasks.  For your use case, your application/script would be using the PAWS API directly and PAWS-M would not be needed (though its possible PAWS-M might provide the capabilities you are looking for without coding yourself :)


The PAWS API should be present on all CUCM servers and has no licensing requirements - free to use.

Cisco Employee

You can also leverage  Cisco Prime collaboration deployment for this task.




Hi Josh,

I faced the same issue researching a solution to reboot Contact Centers at set intervals for best practice.  Another use case is gracefully shutting down UC servers for scheduled maintenance.  In smaller clusters it's not a problem babysitting the cli but it doesn't really scale well.  Since the UC appliance OS doesn't allow scheduling these power related tasks I put together a python script from Dragan's info at this thread:

Below is a python3 script that utilizes the pexpect module to either restart or shutdown a UC appliance.  I use it regularly with cron for scheduled restarts and maintenance windows.  Hope you can find it useful.


#This script utilizes pexpect to ssh to a cisco unified communications server
#and restart or shutdown the system. This script provides the ability to schedule
#graceful power related tasks via cron for maintenance windows and reboot best
#practices. Tested on CUCM/CUC/CCX/CER/IMP/PLM v. 7.x, 8.x 11.x
#os for environemnt variables and file attributes, argv for cli argument variable
#pexpect for connecting to uc device, time for file timestamps

import os, sys, pexpect, time

#dictionary for command and expected result
uc_commands = {
'restart': ' Appliance is being Restarted ...',
'shutdown': ' Appliance is being Powered - Off ...'

#verify command line arguments and display usage if incorrect
if len(sys.argv) != 3 or sys.argv[2] not in uc_commands:
    print('Usage:python3', sys.argv[0].split('/')[-1],'[ip] [restart/shutdown]')

#define global variables
script, ip, command = sys.argv
username = os.environ.get('UC_CLI_USER')
password = os.environ.get('UC_CLI_PASS')
command_result = uc_commands[command]

#display start date/time and hostname
print(time.strftime("%m/%d/%Y %H:%M:%S"), ': Conntecting to %s' % ip)

#pexpect commands
child = pexpect.spawn('ssh -o "StrictHostKeyChecking=no" %s@%s' %
                                (username, ip), encoding='utf-8')
child.logfile_read = sys.stdout #_read so sent commands like password not logged
child.delaybeforesend = .5 #increase send delay for legacy uc server cli
child.sendline('utils system %s' % command)
child.expect('Enter (yes/no)?')
child.send('y') #send individual characters for uc server cli interaction
time.sleep(90) #keep ssh connection active to give uc server time to shutdown
child.close() #close ssh connection to server

#display verification
print('\n'+time.strftime("%m/%d/%Y %H:%M:%S"), ': %s command successfully sent.'
                                                                      % command)