Configure Maintenance Mode During Upgrades

Maintenance mode allows new or updated software to run by automatically whitelisting the incoming software changes in the computer ruleset, while continuing to block blacklisted software. Generally, use the following steps to configure maintenance mode:

  1. Create a Computer object.
  2. Create and configure an ApplicationControlComputerExtension object to turn on maintenance mode. Optionally, set a duration to turn off maintenance mode automatically. Add the ApplicationControlComputerExtension object to the Computer object.
  3. Use a ComputerApi object to turn on maintenance mode on the computer.
  4. Use the ComputerApi object to verify maintenance mode is on.

If you did not set maintenance mode to turn off automatically:

  1. Create a Computer object.
  2. Create and configure an ApplicationControlComputerExtension object to turn off maintenance mode and add it to the Computer object.
  3. Use a ComputerApi object to turn off maintenance mode.

For more information about maintenance mode, see the Deep Security Help Center.

Example: Turn on maintenance mode for a timed duration

The following code example enables maintenance mode for 10 minutes during a scheduled upgrade.

Python
(computer_id, duration, api, configuration, api_version, api_exception):
    """ Turns on maintenance mode on a computer.
    :param computer_id: The ID of the computer.
    :param duration: The maintenance mode duration.
    :param api: The Deep Security API modules.
    :param configuration: Configuration object to pass to the api client.
    :param api_version: The version of the API to use.
    :param api_exception: The Deep Security API exception module.
    :return: A Computer object.
    """

    # Create and configure an ApplicationControlComputerExtesnion object
    application_control = api.ApplicationControlComputerExtension()
    application_control.maintenance_mode_status = "on"
    application_control.maintenance_mode_duration = duration

    # Add the ApplicationControlComputerExtension to a Computer object
    computer = api.Computer()
    computer.application_control_computer_extension = application_control

    try:
        # Update the computer
        computers_api = api.ComputersApi(api.ApiClient(configuration))
        return computers_api.modify_computer(computer_id, computer, api_version)
        
    except api_exception as e:
        return "Exception: " + str(e)
JavaScript
/*
 * Turn on maintenance mode on a computer.
 * @param {Number} computerID The ID of the computer.
 * @param {Number} duration The maintenance mode duration in milliseconds.
 * @param {ApiClient} api The Deep Security API exports.
 * @param {String} apiVersion The api version to use.
 * @returns {Promise} A promise object that resolves to a Computer object. 
 */
exports.turnOnMaintenanceMode = function (computerID, duration, api, apiVersion) {
  // Create and configure an ApplicationControlComputerExtension
  const applicationControl = new api.ApplicationControlComputerExtension();
  applicationControl.maintenanceModeStatus = api.ApplicationControlComputerExtension.MaintenanceModeStatusEnum.on;
  applicationControl.maintenanceModeDuration = duration;

  // Add the ApplicationControlComputerExtension to a computer
  const computer = new api.Computer();
  computer.applicationControl = applicationControl;

  // Update the computer
  const computersApi = new api.ComputersApi();
  return computersApi.modifyComputer(computerID, computer, apiVersion);
};
Java
	/*
 * Turn on maintenance mode on a computer.
 * @param computerId The ID number of the computer.
 * @param duration The duration of the maintenance mode in milliseconds.
 * @param apiVersion The api version.
 */
public static Computer turnOnMaintenanceMode(Integer computerId, Integer duration, String apiVersion) {
	//Create and configure an ApplicationControlComputerExtension
	ApplicationControlComputerExtension applicationControl = new ApplicationControlComputerExtension();
	applicationControl.setMaintenanceModeStatus(MaintenanceModeStatusEnum.ON);
	applicationControl.setMaintenanceModeDuration(duration);
		
	//Create a computer object and add the ApplicationControlComputerExtension
	Computer computer = new Computer();
	computer.setApplicationControl(applicationControl);
		
	//Update the computer
	ComputersApi computersApi = new ComputersApi();
	try {
		return computersApi.modifyComputer(computerId, computer, Boolean.FALSE, apiVersion);
	} catch (ApiException e) {
		e.printStackTrace();
	}
	return null;
}