我能否获得有效的curl命令以从RHEL订阅中删除系统?

时间:2019-04-12 09:19:48

标签: api redhat rhel

我想自动从RHEL订阅中添加和删除VM。我想尽可能使用curl命令并使它保持简单。

我尝试在api.access.redhat.com/management/v1/subscriptions端点上执行curl命令,但出现诸如“缺少身份验证参数”之类的错误。

以下是我正在使用的示例命令:

curl -X GET -s -k -u username:Password "https://api.access.redhat.com/management/v1/subscriptions" -H "accept: application/json"

预期会看到已订阅系统列表,但会收到“缺少身份验证参数”消息。

2 个答案:

答案 0 :(得分:0)

您是否参考过RHEL文档?我不确定是否已经有解决方案,但是请查看“ https://access.redhat.com/articles/3626371#busing-rhsm-apis-in-the-tech-previewb-1

如果在那里找到解决方案,请不要忘记投票。

答案 1 :(得分:0)

为了获得您拥有的所有订阅,请运行以下命令:

curl -H "Authorization: Bearer $access_token" "https://api.access.redhat.com/management/v1/subscriptions"

您可以通过运行以下命令来检索 access_token 变量:

curl https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token -d grant_type=refresh_token -d client_id=rhsm-api -d refresh_token=$offline_token

相反,必须从API Tokens Page生成 offline_token

查看this文章以了解更多详细信息。