首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >租户创建错误-区域设置不能为空。

租户创建错误-区域设置不能为空。
EN

Stack Overflow用户
提问于 2018-12-18 00:19:58
回答 2查看 278关注 0票数 1

这是我第一次发堆叠溢出,谢谢您的耐心!

我试图在深度安全的情况下创建一个新的租户,并得到以下错误:

代码语言:javascript
复制
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."}

,我是不是漏掉了一个地区选项或者别的什么?

代码语言:javascript
复制
#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)
EN

回答 2

Stack Overflow用户

发布于 2018-12-18 15:08:08

在我看来,当地的选择有点小问题。租户区域设置为"en_US“(下划线),管理员区域设置为"en-US”(破折号)。

基于API引用,看起来两者都应该是"en-US“(破折号)。请参阅:2/api-reference?platform=on-premise#operation/createTenant

希望这能帮你解决这个错误。

(FYI,我在趋势微公司工作)

票数 2
EN

Stack Overflow用户

发布于 2018-12-19 23:11:08

对于任何浏览的人:这是我的代码正在工作。api站点没有让我清楚地为租户和管理员添加变量,所以我花了一段时间才弄清楚。

以下是我参考的两篇文章:

2/api-reference?platform=aws#operation/createTenant

2/create-and-manage-tenants?platform=on-premise

您需要在顶部添加您自己的设置和身份验证部分:

代码语言:javascript
复制
# 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)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53824769

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档