Skip to content

How to add a disk to already created VM? #77

@gauravkanojia

Description

@gauravkanojia

Hi there folks, I'm facing issues when trying to add a new additional hard disk to an already created VM. I browsed through https://pve.proxmox.com/pve-docs/api-viewer/ and understood the structure but getting 501 Not Implemented: {"data":null}
Here is my code:

vmIds = array('i', [208])

headIds = array('i', [3302])

vmIdIdx = 0

for HEAD in headIds:
    vmId = vmIds[vmIdIdx]
    headId = 'proxmox-' + str(HEAD)
    print('proxmox-node -->' + headId, ' | VMID -->' + str(vmId))

    qemu_node = proxmox.nodes(headId)
    vm_config_old = qemu_node.qemu(vmIds[vmIdIdx]).config.get()
    print('Host details before adding disk')
    pp.pprint(vm_config_old)

#     pp.pprint(qemu_node.storage.get(storage='xxx-xxxx-vol-xx1')) # This line prints fine
    qemu_node.storage.content.create(filename='var/lib/docker-config',
                                     vmid=vmId, node=headId,
                                     storage='xxx-xxxx-vol-xx1', size='32767M', format='qcow2')
    vm_config_new = qemu_node.qemu(vmIds[vmIdIdx]).config.get()
    print('Host details after adding disk')
    pp.pprint(vm_config_new)
    vmIdIdx = vmIdIdx + 1

Here is the error:

Traceback (most recent call last):
  File "add_disk_to_tr1_vm.py", line 47, in <module>
    storage='netapp-prod-vol-ds1', size='32767M', format='qcow2')
  File "/usr/local/lib/python2.7/site-packages/proxmoxer/core.py", line 96, in create
    return self.post(*args, **data)
  File "/usr/local/lib/python2.7/site-packages/proxmoxer/core.py", line 87, in post
    return self(args)._request("POST", data=data)
  File "/usr/local/lib/python2.7/site-packages/proxmoxer/core.py", line 79, in _request
    resp.content))
proxmoxer.core.ResourceException: 501 Not Implemented: {"data":null}

Any pointers will be helpful.
Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions