5.5. 使用扩展搜索

您可以在 web UI 中找到可用于构建搜索查询的搜索参数。如需更多信息,请参阅 管理 Red Hat Satellite 中的 构建搜索查询

例如,要搜索主机,请完成以下步骤:

  1. 在 Satellite Web UI 中,导航到 Hosts > All Hosts,并点击 Search 字段显示搜索参数列表。
  2. 找到要使用的搜索参数。在本例中,找到 os_titlemodel
  3. 将 API 查询中的搜索参数合并,如下所示:

    请求示例:

    $ curl --insecure --user sat_username:sat_password \
    https://satellite.example.com/api/v2/hosts?search=os_title=\"RedHat+7.7\",model=\"PowerEdge+R330\" \
    | python -m json.tool

    响应示例:

      {
        ...
        "results": [
            {
                "model_id": 1,
                "model_name": "PowerEdge R330",
                "name": "satellite.example.com",
                "operatingsystem_id": 1,
                "operatingsystem_name": "RedHat 7.7",
                ...
            }
        ],
        "search": "os_title=\"RedHat 7.7\",model=\"PowerEdge R330\"",
        "subtotal": 1,
        "total": 11
    }