解决了

如何将类别分配给REST API PRISM CENTRAL内的VM

  • 2021年10月19日
  • 2个答复
  • 126意见

你好

我想在Prism Central中使用REST API将类别分配给VM。

我不知道该怎么做

我需要使用此API吗

- “更新现有VM”(put /vms /{uuid})

或这个API

- “创建或更新类别值”(put/categories/{name}/{value})


我如何使用它来分配新类别而不删除先前的类别?

问候

帕斯卡

图标

最好的答案帕斯卡姆2021年10月19日,09:32

Ahhh finally I answer to myself :-)<\/p>

I have to use\u00a0 \u201cUpdate an existing VM\u201d (put \/vms\/{uuid})<\/p>

and the difficulty for me was to understand what I need to pass for the request payload\/body<\/p>

I need to specify a JSON with the current SPEC of the VM + the metadata with category list<\/p>

{
\u00a0 \"spec\": {
\u00a0\u00a0\u00a0\u00a0\u00a0 < every thing of current vm >
\u00a0 },
\u00a0 \"metadata\": {
\u00a0\u00a0\u00a0 \"kind\": \"vm\"
\u00a0\u00a0\u00a0 \"uuid\": <VM UUID>,
\u00a0\u00a0\u00a0 \"spec_version\": 3,
\u00a0\u00a0\u00a0 \"categories_mapping\": {
\u00a0\u00a0\u00a0\u00a0\u00a0 \"ABC1\": [
\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"abc_1_1\"
\u00a0\u00a0\u00a0\u00a0\u00a0 ],
\u00a0\u00a0\u00a0\u00a0\u00a0 \"TEST2\": [
\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"test1\"
\u00a0\u00a0\u00a0\u00a0\u00a0 ]
\u00a0\u00a0\u00a0 },
\u00a0\u00a0\u00a0 \"categories\": {
\u00a0\u00a0\u00a0\u00a0\u00a0 \"ABC1\": \"abc_1_1\",
\u00a0\u00a0\u00a0\u00a0\u00a0 \"TEST2\": \"test1\"
\u00a0\u00a0\u00a0 }
\u00a0 }
}<\/p>

\u00a0<\/p>

Not so easy to do but it was ok at the end<\/p>

Regards<\/p>","className":"post__content__best_answer"}">

查看原件

该主题已关闭以供评论

2个答复

啊,我终于回答自己:-)

我必须使用“更新现有VM”(put /vms /{uuid})

对我来说,困难是要了解我需要通过的要求有效载荷/身体

我需要指定一个带有VM +当前规格的JSON,带有类别列表

{
“规格”:{
<当前VM>的每件事
},,
“元数据”:{
“善良”:“ VM”
“ uuid”:
“ spec_version”:3,
“ categories_mapping”:{
“ ABC1”:[
“ ABC_1_1”
],,
“ test2”:[
“ test1”
这是给予的
},,
“类别”:{
“ ABC1”:“ ABC_1_1”,
“ test2”:“ test1”
}
}
}

并不容易做,但最后还可以

问候

UserLevel 4
徽章 +5

很高兴听到您找到了想要的东西。如果您想了解有关Nutanix API的更多信息并熟悉如何使用它们,那么您在我们的博客文章中有几篇博客文章nutanix.dev网站。

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