Hey,
I'm trying to clone VM from one node to the other node, using the following code in Python:
However, I only get 401 unathorized error when trying to execute the code, can someone please help with it
For my user I have created an API token with privilege seperation, and it has all the required permissions for that operation: 'VM.Clone'and 'VM.Allocate' 'Datastore.AllocateSpace' 'SDN.Use'
I'm trying to clone VM from one node to the other node, using the following code in Python:
Code:
data = {"name": "censored", # Name for the new cloned virtual machine
"target": "censored2", # The target node where the clone will be created (target_node)
}
headers = {
"Content-Type": "application/json"
}
password = "censored"
user = "censored4"
# Make the HTTP POST request to clone the VM
url = f"https://censored5:8006/api2/json/nodes/censored6/qemu/194/clone"
proxmox_response = requests.post(url, data=data, auth=(user, password), headers=headers)
if proxmox_response.status_code == 200:
print("VM cloning request successful.")
else:
print(f"VM cloning request failed with status code: {proxmox_response.status_code}")
print(proxmox_response.text)
However, I only get 401 unathorized error when trying to execute the code, can someone please help with it
For my user I have created an API token with privilege seperation, and it has all the required permissions for that operation: 'VM.Clone'and 'VM.Allocate' 'Datastore.AllocateSpace' 'SDN.Use'