0

I'm trying to put a computer into maintenance mode in Application Control module inside Deep Security 12 using this Python script via API:

#

import deepsecurity as api
from deepsecurity.rest import ApiException as api_exception
import time, sys, warnings, pprint
import urllib3
urllib3.disable_warnings()

# Setup
configuration = api.Configuration()
configuration.host = 'https://xxxxxxxxxxxx.xxxxxxx.com:4119/api'

# Authentication
configuration.api_key['api-secret-key'] = 'xxxxxxxxxxxxxxxxxxx'

#Initialization
computer_id = "989"
api_version = 'v1'

def turn_on_maintenance_mode():

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

  # 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)

if __name__ == '__main__':
  turn_on_maintenance_mode()

The script executes without any error and the Computer receives the policy change (so communication with the API and this computer is OK), but the Computer not put itself into maintenance mode.

Any ideas of what is happening?

Thanks in advance!

ManU
  • 13
  • 1
  • Hi, you've set the duration of the maintenance mode to 0 -- try increasing the value of `application_control.maintenance_mode_duration` – ScottBro Mar 26 '20 at 13:57
  • Hi, thank you for your message. I've tried with other values like 15, "15", '15', etc. Same results. – ManU Mar 26 '20 at 15:19

1 Answers1

2

computer.application_control_computer_extension = application_control

should be:

computer.application_control = application_control

It seems the sample python code in the Automation Center article for this was incorrect. It should be updated soon.

Oliver Fei
  • 36
  • 1