Skip to content

Conversation

@NemoDacremont
Copy link
Contributor

Changes

Add get vminfo to the new cli, I had to add NewVmRefFromApi in order to properly get the guest information from API only with the Id.

list of changes :

  • Add get vminfo to the new cli
  • Add sdk.NewVmRefFromApi to create a new VmRef with all information from API only with the VmId

Test

This changes can be tested by creating a vm and then retrieving the info with proxmox-api-go get vminfo <id>, here is a snippet that should do the work :

cat << EOF > qemu.json
{
    "name": "test-qemu01",
    "bios": "seabios",
    "tablet": true,
    "memory": {
        "capacity": 2048
    },
    "ostype": "l26",
    "sockets": 1,
    "cpu": {
        "type": "host",
        "cores": 1
    },
    "numa": false,
    "kvm": true,
    "hotplug": "network,disk,usb",
    "boot": "order=ide2;net0",
    "scsihw": "virtio-scsi-pci",
    "network": {
        "0": {
            "bridge": "vmbr0",
            "firewall": true,
            "id": 0,
            "macaddr": "B6:8F:9D:7C:8F:BC",
            "model": "virtio"
        }
    }
}
EOF
NEW_CLI=true ./proxmox-api-go -i create guest qemu -f qemu.json 123 pve
NEW_CLI=true ./proxmox-api-go -i get vminfo 123

It should show :

{
  "id": 123,
  "node": "pve",
  "bios": "seabios",
  "boot": "order=ide2;net0",
  "cpu": {
    "cores": 1,
    "type": "host"
  },
  "description": "",
  "hotplug": "network,disk,usb",
  "memory": {
    "capacity": 2048
  },
  "name": "test-qemu01",
  "protection": false,
  "kvm": true,
  "ostype": "l26",
  "scsihw": "virtio-scsi-pci",
  "smbios1": "uuid=4cad0e7e-046b-4776-aa8d-9985e295f1b0",
  "tablet": true
}

fixes #513

@NemoDacremont
Copy link
Contributor Author

I realized I could use client.CheckVmRef to populate the VmRef with missing data. tbh I don't like the naming, but it's better like that to prevent too much code duplication

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.

migrate: getVmInfo to guest infos

1 participant