Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for unlinking disks from VM #279

Merged
merged 1 commit into from
Dec 6, 2023
Merged

feat: add support for unlinking disks from VM #279

merged 1 commit into from
Dec 6, 2023

Conversation

FredrickB
Copy link
Contributor

@FredrickB FredrickB commented Nov 7, 2023

Added support for unlinking a disk from a VM with optional force-removal. This is the first step to fix an issue
in the Proxmox Terraform provider where the disks are not removed correctly if removed from the HCL as part
of a cloud-init based VM.

Testing

I have tested the changes on a local Proxmox install, version 8.0.4 with the following modified example JSON for creating the Qemu VM:

qemu1.json (supply name of iso-file uploaded to Proxmox node):

{
  "name": "golang1.test.com",
  "desc": "Test proxmox-api-go",
  "memory": 512,
  "os": "l26",
  "cores": 2,
  "sockets": 1,
  "iso": {
    "file": "iso/<some-iso>.iso",
    "storage": "local"
  },
  "disk": {
    "0": {
      "type": "virtio",
      "storage": "local",
      "storage_type": "dir",
      "size": "5G",
      "backup": true
    },
    "1": {
      "type": "virtio",
      "storage": "local",
      "storage_type": "dir",
      "size": "1G",
      "backup": true
    },
    "2": {
      "type": "virtio",
      "storage": "local",
      "storage_type": "dir",
      "size": "1G",
      "backup": true
    }
  },
  "network": {
    "0": {
      "model": "virtio",
      "bridge": "nat"
    }
  }
}
./proxmox-api-go --insecure createQemu 100 <proxmox-node-name> < qemu1.json

Scenarios

Unlink disk, but don't delete it

Should unlink the disk virtio1 and leave it as Unused Disk 0 in tab Hardware of VM

./proxmox-api-go unlink 100 <proxmox-node-name> virtio1

Unlink disk, and delete it

Should unlink the disk virtio2 and remove it from tab Hardware of VM

./proxmox-api-go unlink 100 <proxmox-node-name> virtio2 true

Unlink and delete multiple disks

Should unlink the disks virtio1 and virtio2 and remove both from tab Hardware of VM

./proxmox-api-go unlink 100 <proxmox-node-name> "virtio1,virtio2" true

Client can now perform unlink operation for
a given VM and a set of disks. This is useful
in situations where it's important that the
VM remains while allowing the disks to correctly
be unlinked (detached) and consequently deleted.
@FredrickB FredrickB marked this pull request as ready for review November 7, 2023 21:02
@FredrickB FredrickB marked this pull request as draft November 16, 2023 19:25
@mleone87 mleone87 marked this pull request as ready for review December 6, 2023 10:54
@mleone87 mleone87 merged commit 566d203 into Telmate:master Dec 6, 2023
1 check failed
@FredrickB FredrickB deleted the add-detaching-disks-functionality-to-client branch January 26, 2024 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants