Proxmox - API : Storage content

Tlams

New Member
Sep 12, 2016
11
0
1
34
Hello,

I'm trying to get the storages informations from the proxmox API in python3.x.
Example: https://hyp.lan/api2/json/nodes/hyp/storage/hyp_sto/content"
I don't have problem with my web browser:
{"data":[{"content":"images","size":343597383680,"parent":null,"format":"qcow2","vmid":"103","used":333933707264,"volid":"VMs_XXXX:103/vm-103-disk-1.qcow2"} ...."

But in python, i don't have a result
The others informations like qemu, node... work fine.

I have activate the debug on urllib3:
DEBUG:urllib3.connectionpool:"GET /api2/json/nodes/hyp/storage/hyp_sto/content HTTP/1.1" 200 11
header: Cache-Control header: Connection header: Connection header: Date header: Pragma header: Server header: Content-Length header: Content-Type header: Expires {"data":[]}


I don't understand why i have this response only on this API request.

Thank you !
 
Ho... Yes it's right !
I use a specific user with PVEAuditor permissions and he don't have access to "content"...
The role "datastore audit" not allow this information... why ?
 
Ok, it's work !
I was miss to attribute my usergroup API to the specific storage.
I thought that allow "/" in the datacenter permissions was suffisant to acces for read the storage.

Thx you.
 
Last edited:
EDIT:
No, i can't have acces at all datastore informations with only PVEauditor roles.

The documentation:
https://pve.proxmox.com/wiki/User_Management#Storage_related_privileges

Example:
https://xxxxx:8006/api2/json/nodes/NODE_ID/storage <= OK
{"data":[{"active":1,"content":"images,iso,backup"," ........},

https://xxxxx:8006/api2/json/nodes/NODE_ID/storage/STO_ID <= OK
{"data":[{"subdir":"status"},{"subdir":"content"},{"subdir":"upload"},{"subdir":"rrd"},{"subdir":"rrddata"}]}

https://xxxxx:8006/api2/json/nodes/NODE_ID/storage/STO_ID/content <= NOT OK
{"data":[]}

My user API:
PVEAuditor: Datastore Audit, sys audit, pve audit
Permissions : / (root) => All storage

To have an acces to "content", i must attribute the "Datastore.Allocate" permission. It's not very safe.
 
it works here without problems, whats the output of
Code:
pveversion -v
 
I have the same issue on 3.x and 4.x


user@NODE:~$ pveversion -v
proxmox-ve: 4.1-41 (running kernel: 4.2.8-1-pve)
pve-manager: 4.1-22 (running version: 4.1-22/aca130cf)
pve-kernel-4.2.8-1-pve: 4.2.8-41
lvm2: 2.02.116-pve2
corosync-pve: 2.3.5-2
libqb0: 1.0-1
pve-cluster: 4.0-36
qemu-server: 4.0-64
pve-firmware: 1.1-7
libpve-common-perl: 4.0-54
libpve-access-control: 4.0-13
libpve-storage-perl: 4.0-45
pve-libspice-server1: 0.12.5-2
vncterm: 1.2-1
pve-qemu-kvm: 2.5-9
pve-container: 1.0-52
pve-firewall: 2.0-22
pve-ha-manager: 1.0-25
ksm-control-daemon: 1.2-1
glusterfs-client: 3.5.2-2+deb8u1
lxc-pve: 1.1.5-7
lxcfs: 2.0.0-pve2
cgmanager: 0.39-pve1
criu: 1.6.0-1


http://image.noelshack.com/fichiers/2016/37/1473775023-proxmox.png
 
did you add the permission using the gui?
if yes, i believe there is a fix in a later version

but anyway, please update to the latest version, and try again
 
I tried with CLI and GUI.
root@node:~ # pveum aclmod / -user userapi@pve -role PVEAuditor
Tomorrow I will test with a newer version and i will return you the result.

My objective is to calcul the real disk allocation. Indeed with qemu disk, we can sur-allocate and the information available in "/storage" show only the disk currently used.
 
Last edited:
Same result with a recent pve version

root@pve:~# pveversion -v
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "fr_FR.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
proxmox-ve: 4.2-48 (running kernel: 4.4.6-1-pve)
pve-manager: 4.2-2 (running version: 4.2-2/725d76f0)
pve-kernel-4.4.6-1-pve: 4.4.6-48
lvm2: 2.02.116-pve2
corosync-pve: 2.3.5-2
libqb0: 1.0-1
pve-cluster: 4.0-39
qemu-server: 4.0-72
pve-firmware: 1.1-8
libpve-common-perl: 4.0-59
libpve-access-control: 4.0-16
libpve-storage-perl: 4.0-50
pve-libspice-server1: 0.12.5-2
vncterm: 1.2-1
pve-qemu-kvm: 2.5-14
pve-container: 1.0-62
pve-firewall: 2.0-25
pve-ha-manager: 1.0-28
ksm-control-daemon: 1.2-1
glusterfs-client: 3.5.2-2+deb8u1
lxc-pve: 1.1.5-7
lxcfs: 2.0.0-pve2
cgmanager: 0.39-pve1
criu: 1.6.0-1
zfsutils: 0.6.5-pve9~jessie
 
Same result with a recent pve version

root@pve:~# pveversion -v
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "fr_FR.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
proxmox-ve: 4.2-48 (running kernel: 4.4.6-1-pve)
pve-manager: 4.2-2 (running version: 4.2-2/725d76f0)
pve-kernel-4.4.6-1-pve: 4.4.6-48
lvm2: 2.02.116-pve2
corosync-pve: 2.3.5-2
libqb0: 1.0-1
pve-cluster: 4.0-39
qemu-server: 4.0-72
pve-firmware: 1.1-8
libpve-common-perl: 4.0-59
libpve-access-control: 4.0-16
libpve-storage-perl: 4.0-50
pve-libspice-server1: 0.12.5-2
vncterm: 1.2-1
pve-qemu-kvm: 2.5-14
pve-container: 1.0-62
pve-firewall: 2.0-25
pve-ha-manager: 1.0-28
ksm-control-daemon: 1.2-1
glusterfs-client: 3.5.2-2+deb8u1
lxc-pve: 1.1.5-7
lxcfs: 2.0.0-pve2
cgmanager: 0.39-pve1
criu: 1.6.0-1
zfsutils: 0.6.5-pve9~jessie

that's not up to date at all..