One of the most common tasks we have is suppressing alarms for planned outages using maintenance mode. It can be tedious to do this manually. Linked is an example of how you can do it using the UIM API. You are welcome to have the code and make modifications / improvements to it. I am sure the real programmers will take one look at what I have written and run screaming to fix it.
Start by setting up some logging the levels include logging.DEBUG (most logging) to logging.CRITICAL (least logging)
Now let us build the data needed to create our maintenance schedule. In this case we are creating a 1 time schedule for March 3, 2018 at 4PM New York time and it will last for 4 hours
We now need to get information about the UIM REST API from a configuration file as well as the list of systems we want to put in maintenance mode
The configuration file config.ini is in the sample format below
The system.txt file simply has 1 system on each line. We use the IP address of the machine to find it in DNS if that fails we search UIM using the name.
Now that we have all the data we need let us create the maintenance schedule by passing the uim_ws (UIM REST API information), the name of the schedule, the description, the start time, the duration and the timezone we want it to honor
The above returns a schedule id. Let us get the list of systems from the file and use that to find the cs_id (see the cm_computer_system table in the UIM DB)
With the list of cs_id in returned we will then add them to maintenance schedule using the id from above
That's it. The real code is available in GitHub cauimws/maintenancemode.py at master · adgayle/cauimws · GitHub
Feel free to use it and make improvements. This is very generic and can be improved to accept the options as parameters instead of hard coding them. This is just to get you started.