Skip to content

希望能够正确地传递limit Hopefully the limit can be passed correctly #2

@KongNan

Description

@KongNan

当我提示设置用于限定执行主机的limit时,总是无法正常调用。但自行测试编写的代码(通过body传递limit的data)可以正常执行。是我哪里做错了吗?
When I prompt to set the limit for limiting the execution host, it always failed to call normally. However, the following code for testing (passing the limit data through the body) can be executed normally. Is there something I did wrong with mcp? (Sorry for my English!)

example code (work ok):

import sys

# # 检查命令行参数
# if len(sys.argv) != 2:
#     print("usage: python awxCall.py <limit>")
#     sys.exit(1)

# AWX配置
awx_url = "http://example.com"
api_token = ""
job_template_id = 110  

limit_value = "MY_HOST"  # 指定要覆盖的主机模式 【模式1: 在此指定】
# limit_value = sys.argv[1]   # 指定要覆盖的主机模式   【模式2: 读命令行】   # 从命令行获取limit_value


# API端点
launch_endpoint = f"{awx_url}/api/v2/job_templates/{job_template_id}/launch/"

# 请求头
headers = {
    "Content-Type": "application/json",
    "Authorization": f"Bearer {api_token}"
}

# 请求体
data = {
    "limit": limit_value
}

# 发送POST请求
response = requests.post(launch_endpoint, headers=headers, json=data)

# 处理响应
if response.status_code == 201:
    print("OK!")
    job_data = response.json()
    print(f"job ID: {job_data['id']}")
else:
    print(f"error! status : {response.status_code}")
    print("response:", response.text)```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions