hi,
After login to prism , i open API Reference and login with credentions.
Then i go to VMs-->Clone Section to clone vm via API.
I get the vm uuid via two method which on i think i get same uuid
1)ssh to cvm and giving “acli vm.list”
2)While console url, using uuid=”string”
Both have same uuid. So i used to clone vm via api but i get error as “
Given input is invalid. VM UUID cannot be specified, use idempotence identifiers to get the UUID
”
I also tried get existing and create new idempotence identifiers but on executing it in clone vm it gives error “uuid not existed”.
Please suggest me ,i think uuid is correct but then what causing the error.
Please help.
Best answer by AnishWalia20
hey,
Using the above POST method you can get the idempotence identifier of the VM.
Also as the above documentation suggests It is mandatory to provide the count for how many identifiers we need and the lifetime until we can use it in the POST “/idempotence_identifiers” API.
Below is an example with CURL:
anish.singhwalia@C02XF4HA:~$ curl -k -X POST --header "Content-Type: application/json" --header
"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"]}
We can use now the returned idempotence identifier(a1d6b81b-a76c-495c-9a71-508167f810dd) in the /clone API
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\"
}
}" "https://10.136.107.69:9440/api/nutanix/v3/vms/9276242d-34r1-69f3-dfe8-5d1cb15569k2/clone"
{"task_uuid": "9bb26a3e-18cf-4fea-941a-cfe5e542c076"}
Now we can check the above task details and 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"
{"status": "SUCCEEDED", "last_update_time": "2019-12-23T08:01:31Z", "logical_timestamp": 2, "entity_reference_list": [{"kind": "vm", "uuid": "a1d6b81b-a76c-495c-9a71-508167f810dd"}], "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"}, "subtask_reference_list": [], "completion_time": "2019-12-23T08:01:31Z", "creation_time_usecs": 1577088078874113, "progress_message": "", "operation_type": "ProcessVmClone", "completion_time_usecs": 1577088091347015, "percentage_complete": 100, "api_version": "3.1", "uuid": "9bb26a3e-18cf-4fea-941a-cfe5e542c076"}
I hope the above clarifies the procedure and helps you
Let me know if you need anything else.