解决了

无法通过API 3.0克隆VM

  • 2021年1月22日
  • 4个答复
  • 265次观看

徽章“title= +1

你好,

登录到棱镜后,我打开API参考并登录信誉。

然后,我转到VM->克隆部分通过API到克隆VM。

我通过两种方法获得VM UUID,我认为我会得到同样的uuid

1)SSH到CVM并给出“ ACLI VM.LIST”

2)当控制台URL时,使用uuid =“字符串”

两者都有相同的uuid。因此,我曾经通过API克隆VM,但我会遇到错误作为“

给定的输入无效。无法指定VM UUID,使用IDEMPOTENCE标识符获取UUID

透明

我还尝试了存在并创建新的IDEMPOTENCE标识符,但是在克隆VM中执行它时,它给出了“不存在UUID”的错误。

请建议我,我认为UUID是正确的,但是是什么导致错误。

请帮忙。

图标

最好的答案Anishwalia202021年1月23日,09:40

hey,\u00a0@Balram<\/user-mention>\u00a0here are more details about the \u201c\/idempotence_identifiers<\/strong>\u201d REST API:\u00a0https:\/\/www.nutanix.dev\/reference\/prism_central\/v3\/api\/idempotence-identifiers\/postidempotenceidentifiers\/<\/a><\/p>

\u00a0<\/p>

Using the above POST method you can get the idempotence identifier<\/strong> of the VM.\u00a0<\/p>

Also as the above documentation suggests\u00a0It is mandatory to provide the count for how many identifiers we need and the lifetime until we can use it in the POST \u201c\/idempotence_identifiers<\/strong>\u201d\u00a0API.\u00a0<\/p>

Below is an example with CURL:
\u00a0<\/p>

anish.singhwalia@C02XF4HA:~$ curl -k -X POST --header \"Content-Type: application\/json\" --header\u00a0<\/p>

\"Accept: application\/json\" --header \"Authorization: Basic AYWtrr7y23TnV0YW5peC8\" -d \"{
\\\"count\\\": 1,
\\\"valid_duration_in_minutes\\\": 527040
}\" \"https:\/\/10.136.107.69:9440\/api\/nutanix\/v3\/idempotence_identifiers\"
{\"client_identifier\": null, \"count\": 1, \"expiration_time\": \"2020-12-23T07:59:57Z\", \"uuid_list\": [\"a1d6b81b-a76c-495c-9a71-508167f810dd<\/strong>\"]}<\/p>



We can use now the returned idempotence identifier(a1d6b81b-a76c-495c-9a71-508167f810dd<\/strong>) in the \/clone API<\/strong>

anish.singhwalia@C02XF4HA::~$ curl -k -X POST --header \"Content-Type: application\/json\" --header \"Accept: application\/json\" --header \"Authorization: Basic AYWtrr7y23TnV0YW5peC8\" -d \"{
\\\"metadata\\\": {
\\\"uuid\\\": \\\"a1d6b81b-a76c-495c-9a71-508167f810dd<\/strong>\\\"
}
}\" \"
https:\/\/10.136.107.69:9440\/api\/nutanix\/v3\/vms\/9276242d-34r1-69f3-dfe8-5d1cb15569k2\/clone<\/a>\"
{\"task_uuid\": \"9bb26a3e-18cf-4fea-941a-cfe5e542c076<\/strong>\"}<\/p>

\u00a0<\/p>

Now we can check the above task details\u00a0and identify the UUID of the cloned VM:


anish.singhwalia@C02XF4HA:~$ curl -k -X GET --header \"Accept: application\/json\" --header \"Authorization: Basic AYWtrr7y23TnV0YW5peC8\" \"
https:\/\/10.136.10769:9440\/api\/nutanix\/v3\/tasks\/9bb26a3e-18cf-4fea-941a-cfe5e542c076<\/a>\"
{\"status\": \"SUCCEEDED\", \"last_update_time\": \"2019-12-23T08:01:31Z\", \"logical_timestamp\": 2, \"entity_reference_list\": [{\"kind\": \"vm\", \"uuid\": \"a1d6b81b-a76c-495c-9a71-508167f810dd<\/strong>\"}], \"start_time\": \"2019-12-23T08:01:18Z\", \"creation_time\": \"2019-12-23T08:01:18Z\", \"start_time_usecs\": 1577088078927590, \"cluster_reference\": {\"kind\": \"cluster\", \"uuid\": \"r4fd3d69-3df4-5g3d-448e-6b9312655365<\/strong>\"}, \"subtask_reference_list\": [], \"completion_time\": \"2019-12-23T08:01:31Z\", \"creation_time_usecs\": 1577088078874113, \"progress_message\": \"//www.jhbzcj.com/next/prism-for-infra-and-it-ops-26/\", \"operation_type\": \"ProcessVmClone\", \"completion_time_usecs\": 1577088091347015, \"percentage_complete\": 100, \"api_version\": \"3.1\", \"uuid\": \"9bb26a3e-18cf-4fea-941a-cfe5e542c076<\/strong>\"}<\/p>

\u00a0<\/p>

I hope the above clarifies the procedure and helps you\u00a0@Balram<\/user-mention>\u00a0.<\/p>

Let me know if you need anything else.\":sweat_smile:\"<\/p>

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

查看原件

该主题已关闭以供评论

4个答复

嗨,巴拉姆,

/克隆API期望具有同步标识符。
为了获得IDEMPOTENCE标识符,我们可以使用API​​ IDEMPOTENCE_IDENDIFIER。
必须为我们需要多少标识符和寿命提供计数,直到我们可以使用它为止。

如果可能的话,您可以打开支持案例,以便可以研究细节吗?

嘿, @balram以下是有关“/idempotence_Identifiers” REST API:https://www.nutanix.dev/reference/prism_central/v3/api/idempotence-indentifiers/postidempotenceidentifiers/

使用上述文章方法,您可以得到掌位标识符VM。

同样,正如上面的文档所表明的那样,必须为我们需要多少标识符和寿命提供计数,直到我们可以在帖子中使用它为止”/idempotence_Identifiers” API。

以下是卷曲的示例:

anish.singhwalia@c02xf4ha:〜$ curl -k -k -x帖子-HEADER -HEADER“ content -type:application/json” - 负责人

“ ACCEPT:应用程序/JSON” - -HEADER”授权:BASIC AYWTRR7Y23TNV0YW5PEC8“ -D” {
\“ count \”:1,
\“有效_duration_in_minutes \”:527040
}“” https://10.136.107.69:9440/api/nutanix/v3/idempotence_identifiers”
{“ client_identifier”:null,“ count”:1,“ expiration_time”:“ 2020-12-23T07:59:57Z”,“ uuid_list”:[A1D6B81B-A76C-495C-9A71-508167F810DD”]]}



我们现在可以使用返回的IDEMPOTENCE标识符(A1D6B81B-A76C-495C-9A71-508167F810DD) 在里面/克隆API

anish.singhwalia@c02xf4ha ::〜$ curl -k -k -x post -header“ content -type:application/json” - -header“ convage:application/json” - -header“ - -HEADER”授权:基本AYWTRR7Y23TNV0YW5PEC8” -D
\“元数据\”:{
\“ uuid \”:\”A1D6B81B-A76C-495C-9A71-508167F810DD\”
}
}“”https://10.136.107.69:9440/api/nutanix/v3/vms/9276242d-34r1-69f3-dfe8-5dfe8-5d1cb15569k2/clone
{“ task_uuid”:”9BB26A3E-18CF-4FEA-941A-CFE5E542C076“}

现在,我们可以检查上述任务详细信息并确定克隆VM的UUID:


anish.singhwalia@c02xf4ha:〜$ curl -k -k -x get -header“ Accept:application/json” - -Header“授权:基本AYWTRR7Y23TNV0YW5PEC8”“”https://10.136.10769:9440/api/nutanix/v3/tasks/9BB26A3E-18CF-4FEA-941A-CFE5E542C076
{“状态”:“成功”,“ last_update_time”:“ 2019-12-23T08:01:31Z”,“ logical_timestamp”:2,“ entity_reference_list”:[{and and off {n-nick'':“”:“ vm”,“ uuid”,“ uuid”:uuid“:”:“”:“”:“”:“”:“”:A1D6B81B-A76C-495C-9A71-508167F810DD“}],“ start_time”:“ 2019-12-23T08:01:18Z”,“ creation_time”:“ 2019-12-23T08:01:18Z”,“ start_time_usecs”:157770808078078927590:“群集”,“ uuid”:“”R4FD3D69-3DF4-5G3D-448E-6B9312655365“},” subtask_reference_list“:[],“ plote_time”:“ 2019-12-23T08:01:31Z”,“ creation_time_usecs”:15777088078874113,“ progress_message”::1577088091347015,“ percentage_complete”:100,“ api_version”:“ 3.1”,“ uuid”:“”9BB26A3E-18CF-4FEA-941A-CFE5E542C076“}

我希望以上阐明该程序并为您提供帮助 @balram

需要帮助请叫我。:Sweat_smile:“src=

徽章“title= +1

谢谢,我明白了,它也有效

徽章“title= +1

你好 @anishwalia20

此API正在起作用,但在VM克隆之后。它在状态下处于电力上。

是否有任何方法可以通过API 3在状态下设置权力(在API 2中,它在那里,但它的旧且弃用不起作用)

要么

创建VM或克隆的任何其他方法,以便它在状态下掌权。

Baidu