How to find out if a clone is complete via the api.

Daxcor

Member
Oct 31, 2021
38
2
13
57
Here is the cluster log:

"msg": "end task UPID:temppve:0034DAC7:06B4A3DE:67C8E109:qmclone:10000:foundry@pve!foundryapi: OK",

it only shows the template vmid and not the target vmid. I am trying to figure out how to test of the clonning of a specific vmid is completed. The task log doesn't show anything useful either. There could be more than one cloning going on and I need to figure out which one has completed. This seems to be the only function that is like this. Any ideas on how a guy can do this?

Thanks
Brad
 
it only shows the template vmid and not the target vmid.
When you initiate the clone via API newid is a required field, so you know what the new ID is.
The task log doesn't show anything useful either
When you start the clone you get task UPID. When you query that task UPID you get status and exit status. The status could be running or stopped (may be something else). Exit status should be OK.

You could also get a list of tasks that have type "qmclone" and query them all.


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
Last edited:
The task and cluster logs only show that a clone has started and completed. However it doesn't show which vmid (new machine) that clone log entry references to. If two different clones happen at the same time, there is no way to know which one is done. If you look at the example task entry I posted, it only shows the template vmid with no way to reference the new vm it created. There is no way to connect the two events. Query the upid returns no helpful information.
 
you have it backwards ;)

you start a clone for VMID -> NEWID and get back a UPID

if you want to know whether the clone into NEWID is done, you check *that UPID*
 
sorry, the doc's doesn't show that anything is returned. I hadn't tried the process manually to actually see what was returned.

1741276932089.png

Thank you for the help.
 
all task-spawning API endpoints will return the UPID so that you can query the task status and/or log ;)
 
Ok, so far things are looking good. However, I am noticing that the name of the vm gets changed AFTER the clone has completed. So it starts out "VM 2000" and then eventually changes to "bob". It looks like when I search for the upid to find out if it is completed, I get an exitstatus = ok before the name has been set. To get the vmid/node of my vm to act on I do a `/api2/json/cluster/resources?type=vm` Then I do a find on the results. Due to timing the name "bob" isn't found only "VM 2000". Is this expected behavior of the clone function?
 
To get the vmid/node of my vm to act on I do a `/api2/json/cluster/resources?type=vm` Then I do a find on the results. Due to timing the name "bob" isn't found only "VM 2000". Is this expected behavior of the clone function?
I've never noticed it. Where does "bob" come from? Is it the name stored in the template? Are you observing the name change in GUI? If so, the UI is often delayed as it polls the backend. As far as I know when the task is complete there are no more clone related changes being done.

That being said, why are you searching for name? The name attribute is _not_ unique. You can have multiple VMs with the same name. The ID is unique. You know the ID of the new VM as you supplied it during the clone create, you should really use ID for any interaction.


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
You are correct, my whole code base uses the username as a primary index so I just continued here in proxmox. Once you pointed that out I can see that it can't work in this context.