0

我正在尝试使用此 Python 脚本通过 API 将计算机置于 Deep Security 12 内的应用程序控制模块中的维护模式:

#

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

脚本执行没有任何错误,并且计算机接收到策略更改(因此与 API 和这台计算机的通信正常),但计算机没有将自身置于维护模式。

对正在发生的事情有任何想法吗?

提前致谢!

4

1 回答 1

2

computer.application_control_computer_extension = application_control

应该:

computer.application_control = application_control

自动化中心文章中的示例 python 代码似乎不正确。它应该很快更新。

于 2020-03-27T19:46:22.643 回答