vm param for cluster resource endpoint returns no results

tglynn

New Member
Aug 30, 2024
3
1
3
Hello!

I'm playing a bit with the proxmox API, and I can't understand the results that I'm seeing. I can successfully get all nodes in the cluster:


❯ curl -s -H 'Authorization: PVEAPIToken=$MY_TOKEN_HERE' 'https://$PROXMOX_HOST/api2/json/cluster/resources?type=node'

{"data":[{"level":"","id":"node/proxmox02","type":"node","cgroup-mode":2,"node":"proxmox02","status":"online"},{"level":"","id":"node/proxmox03","node":"proxmox03","cgroup-mode":2,"type":"node","status":"online"},{"status":"online","id":"node/proxmox01","type":"node","cgroup-mode":2,"node":"proxmox01","level":""}]}%

But changing the type param to `vm` returns no results

❯ curl -s -H 'Authorization: PVEAPIToken=$MY_TOKEN_HERE' 'https://$PROXMOX_HOST/api2/json/cluster/resources?type=vm'
{"data":[]}%



The CLI tool correctly sees my vms:

root@proxmox01:/var/log/pveproxy# pvesh get /cluster/resources --type vm | grep qemu | wc -l
34

I started with a readonly scoped token (which should work here) but also kicked it up to a full admin access token with no change in the results.


Any idea what I'm missing? This is version 8.2.4
 
Huh, does this type param just not work at all for this endpoint?

I set up a fresh install of 8.2.2 (the newest downloadable ISO from proxmox.com, grabbed this morning), made two test qemu vms, and snagged a root token. Seems like the same story.

pvesh can show them

root@proxmoxtest01:~# pvesh get /cluster/resources --type vm


┌──────────┬──────┬─────────────┬─────────┬───────┬────────┬─────────┬───────┬────────┬───────────┬──────────┬────────┬─────────┬───────────────┬────────────┬──────┬─────────┬─────────┬────────┬──────┐


│ id │ type │ cgroup-mode │ content │ cpu │ disk │ hastate │ level │ maxcpu │ maxdisk │ maxmem │ mem │ name │ node │ plugintype │ pool │ status │ storage │ uptime │ vmid │


╞══════════╪══════╪═════════════╪═════════╪═══════╪════════╪═════════╪═══════╪════════╪═══════════╪══════════╪════════╪═════════╪═══════════════╪════════════╪══════╪═════════╪═════════╪════════╪══════╡


│ qemu/100 │ qemu │ │ │ 0.00% │ 0.00 B │ │ │ 1 │ 32.00 GiB │ 2.00 GiB │ 0.00 B │ testvm1 │ proxmoxtest01 │ │ │ stopped │ │ 0s │ 100 │


├──────────┼──────┼─────────────┼─────────┼───────┼────────┼─────────┼───────┼────────┼───────────┼──────────┼────────┼─────────┼───────────────┼────────────┼──────┼─────────┼─────────┼────────┼──────┤


│ qemu/101 │ qemu │ │ │ 0.00% │ 0.00 B │ │ │ 1 │ 32.00 GiB │ 2.00 GiB │ 0.00 B │ testvm2 │ proxmoxtest01 │ │ │ stopped │ │ 0s │ 101 │


└──────────┴──────┴─────────────┴─────────┴───────┴────────┴─────────┴───────┴────────┴───────────┴──────────┴────────┴─────────┴───────────────┴────────────┴──────┴─────────┴─────────┴────────┴──────┘




But the api call only returns nodes, not vms or storage:

❯ curl -s --insecure -H 'Authorization: PVEAPIToken=root@pam!testapi=7f47efc7-e2ba-4fb6-a727-9bb5badc0c58' 'https://192.168.50.21:8006/api2/json/cluster/resources?type=node'


{"data":[{"node":"proxmoxtest01","id":"node/proxmoxtest01","cgroup-mode":2,"type":"node","level":"","status":"online"}]}[B]%[/B] ❯ curl -s --insecure -H 'Authorization: PVEAPIToken=root@pam!testapi=7f47efc7-e2ba-4fb6-a727-9bb5badc0c58' 'https://192.168.50.21:8006/api2/json/cluster/resources?type=vm'


{"data":[]}[B]%[/B] ❯ curl -s --insecure -H 'Authorization: PVEAPIToken=root@pam!testapi=7f47efc7-e2ba-4fb6-a727-9bb5badc0c58' 'https://192.168.50.21:8006/api2/json/cluster/resources?type=storage'


{"data":[]}[B]%[/B] [B]~[/B] ❯ 09:25:14



It's definitely looking for a type param of either vm, storage, sdn, or node, since it'll kick back invalid value if you try something outside of the documented enum

❯ curl -s --insecure -H 'Authorization: PVEAPIToken=root@pam!testapi=7f47efc7-e2ba-4fb6-a727-9bb5badc0c58' 'https://192.168.50.21:8006/api2/json/cluster/resources?type=bogus'


{"data":null,"errors":{"type":"value 'bogus' does not have a value in the enumeration 'vm, storage, node, sdn'"}}[B]%[/B] [B]~[/B] ❯ 09:26:52



(I didn't bother redacting the token - this is a fresh test cluster that I'm deleting now)
 
Last edited:
Hi @tglynn , welcome to the forum.

It's definitely looking for a type param of either vm, storage, sdn, or node, since it'll kick back invalid value if you try something outside of the documented enum
The allowed parameter values can be found in the API documentation: https://pve.proxmox.com/pve-docs/api-viewer/#/cluster/resources

You are looking for "qemu":
Code:
type
enum
 
node | storage | pool | qemu | lxc | openvz | sdn
Resource type.



Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
Thanks! I don't think that's right. That's what that endpoint returns, not what that endpoint is looking for in the parameters. The param enum is just above that

typeenum vm | storage | node | sdn



I got an answer on the proxmox subreddit - I didn't realize that I'd enabled privilege separation on that API token, which meant I could get nodes but not vms, even when using a token scoped to the root user. Toggling that worked, and let me switch to using the readonly role to get what I was looking for.
 
  • Like
Reactions: bbgeek17

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!