租户创建错误-语言环境不能为空

时间:2018-12-18 00:19:58

标签: deepsecurity

这是我第一次发帖至堆栈溢出,感谢您的耐心等待!

我正在尝试在深度安全性中创建新的租户,并且正在获取此租户 错误:

An exception occurred when calling TenantsApi.create_tenant: (400)
Reason: 
HTTP response headers: HTTPHeaderDict({'X-Frame-Options': 'SAMEORIGIN', 'X-XSS-Protection': '1;mode=block', 'Cache-Control': 'no-cache,no-store', 'Pragma': 'no-cache', 'X-DSM-Version': 'Deep Security/11.2.225', 'Content-Type': 'application/json', 'Content-Length': '44', 'Date': 'Mon, 17 Dec 2018 23:39:16 GMT', 'Connection': 'close'})
HTTP response body: {"message":"Account locale cannot be null."}

我是否缺少语言环境选项?

#import, setup, authentication related info removed

tenant = deepsecurity.Tenant()
api_version = 'v1'
bypass_tenant_cache = False
confirmation_required = False
asynchronous = False

def create_tenant(client, configuration, api_version, api_exception, account_name):

    # Define the administrator account
    admin = client.Administrator()
    admin.username = "TenantAdmin"
    admin.password = "Pas$w0rd"
    admin.email_address = "example@email.com"
    admin.receive_notifications = "false"
    admin.role_id = 1
    admin.locale = "en_US"

    tenant = client.Tenant(administrator=admin)
    modules = client.Tenant.modules_visible = ["anti-malware", "firewall", "intrusion-prevention"]
    tenant.modules_visible = modules
    tenant.name = 'api-woot'
    tenant.locale = "en-US"
    tenant.description = "Test tenant."

    try:
        tenants_api = client.TenantsApi(client.ApiClient(configuration))
        return tenants_api.create_tenant(tenant, api_version, confirmation_required=False)

    except api_exception as e:
        return "Exception: " + str(e)
try:
        api_response = api_instance.create_tenant(tenant, api_version, bypass_tenant_cache=bypass_tenant_cache, confirmation_required=confirmation_required, asynchronous=asynchronous)
        pprint(api_response)
except ApiException as e:
        print("An exception occurred when calling TenantsApi.create_tenant: %s\n" % e)

2 个答案:

答案 0 :(得分:2)

对于我来说,本地选项似乎是一个小问题。租户区域设置为“ en_US”(下划线),管理员区域设置为“ en-US”(破折号)。

根据API参考,两者似乎都应为“ en-US”(破折号)。参见:https://automation.deepsecurity.trendmicro.com/article/11_2/api-reference?platform=on-premise#operation/createTenant

希望为您解决此错误。
(仅供参考,我在趋势科技工作)

答案 1 :(得分:0)

对于浏览的其他任何人:这是我正在运行的代码。 api网站对我来说还不够清楚,无法为租户和管理员添加变量,因此花了我一段时间才弄清楚

这是我参考的2篇文章:

https://automation.deepsecurity.trendmicro.com/article/11_2/api-reference?platform=aws#operation/createTenant

https://automation.deepsecurity.trendmicro.com/article/11_2/create-and-manage-tenants?platform=on-premise

您需要在顶部添加自己的设置和身份验证项,然后:

# Initialization
# Set Any Required Values
api_instance = deepsecurity.TenantsApi(deepsecurity.ApiClient(configuration))
tenant = deepsecurity.Tenant()
tenant.locale = "en-US"
tenant.name = "api-woot"
tenant.description = "test tenant"

admin = deepsecurity.Administrator()
admin.username = "tenantadmin"
admin.role_id = 1
admin.password = "Pas$w0rd"
admin.full_name = "bob admin"
admin.email_address = "a@email.com"
admin.receive_notifications = "false"
tenant.administrator = admin

api_version = 'v1'
bypass_tenant_cache = False
confirmation_required = False
asynchronous = False

try:
        api_response = api_instance.create_tenant(tenant, api_version, bypass_tenant_cache=bypass_tenant_cache, confirmation_required=confirmation_required, asynchronous=asynchronous)
        pprint(api_response)
except ApiException as e:
        print("An exception occurred when calling TenantsApi.create_tenant: %s\n" % e)