Maintenance Mode to one computer in Application Control inside Deep Security 12

193 Views Asked by At

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!

1

There are 1 best solutions below

2
On BEST ANSWER

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.