解决了

API呼叫运行书并通过变量

  • 2021年11月11日
  • 2个答复
  • 100次观看

我有与主题相同的问题(https://next.nutanix.com/calm-application-management-55/passing-variobles-to-calm-runbooks-39356

我创建了一本Runbook,在Runbook的“配置”部分下配置了一个变量。

我可以通过API启动Runbook,但它不会传递该值。
我尝试将以下样本作为请求的主体传递。

我想念什么?

{
“规格”:{
“ args”:[[
{
“名称”:“ variablename”,
“ value”:“ value”
}
这是给予的
}
}

图标

最好的答案乔森纳克斯2021年11月11日,18:02

Hi Peter,<\/p>

I have tested again and it is working for me. Steps to reproduce:<\/p>

  1. Create a runbook with a single Execute Escript task that has:\u00a0\t
    print(\u201c@@{VAR_TEST}@@\u201d)<\/code><\/pre>\t<\/li>\t
  2. Add in the runbook a variable called VAR_TEST<\/strong> and enable runtime<\/u> icon\t
    \"//www.jhbzcj.com/next/calm-application-management-55/\"<\/figure>

    \u00a0<\/p>\t<\/li>\t

  3. Gather the UUID for the runbook from the URL on the top\t
    \"//www.jhbzcj.com/next/calm-application-management-55/\"<\/figure>

    \u00a0<\/p>\t<\/li>\t

  4. With Postman or curl, run a POST call to\u00a0https:\/\/PC_IP:9440\/api\/nutanix\/v3\/runbooks\/<runbook_uuid>\/run<\/a>\u00a0with body that has:\t
    {
    \"spec\": {
    \"args\": [
    {
    \"name\": \"VAR_TEST\",
    \"value\": \"THIS IS A TEST\"
    }
    ]
    }
    }<\/code><\/pre>\t

    \u00a0<\/p>\t<\/li><\/ol>","className":"post__content__best_answer"}">

查看原件

该主题已关闭以供评论

2个答复

UserLevel 4
徽章 +5

嗨,彼得,

我再次进行了测试,它对我有用。重现步骤:

  1. 创建一个具有单个执行的Escript任务的运行书,该任务具有:
    打印(“ @@ {var_test} @@”)
  2. 添加运行本的变量称为var_test启用运行时图标

  3. 从顶部的URL收集运行书的UUID

  4. 使用Postman或Curl,请在https:// pc_ip:9440/api/nutanix/v3/runbooks//run有:
    {
    “规格”:{
    “ args”:[[
    {
    “名称”:“ var_test”,
    “值”:“这是一个测试”
    }
    这是给予的
    }
    }

问题是由于我没有启用“启用运行时”选项。

非常感谢您的及时答复!

Learn more about our cookies.<\/a>","cookiepolicy.button":"Accept cookies","cookiepolicy.button.deny":"Deny all","cookiepolicy.link":"Cookie settings","cookiepolicy.modal.title":"Cookie settings","cookiepolicy.modal.content":"We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.<\/a>","cookiepolicy.modal.level1":"Basic
Functional","cookiepolicy.modal.level2":"Normal
Functional + analytics","cookiepolicy.modal.level3":"Complete
Functional + analytics + social media + embedded videos"}}}">
Baidu