]> git.proxmox.com Git - pve-manager.git/commitdiff
api: ceph pools: add type to returned properties
authorAaron Lauterer <a.lauterer@proxmox.com>
Mon, 2 May 2022 12:36:24 +0000 (14:36 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 2 May 2022 13:43:11 +0000 (15:43 +0200)
The osd dump already contains the pool type in numerical format.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Dominik Csapak <d.csapak@proxmox.com>
PVE/API2/Ceph/Pools.pm

index efdee36063af83c4538529ad229dc736155dc9fa..7042727724217873d9a4ba98ac00d5e51d4bb9f2 100644 (file)
@@ -66,6 +66,11 @@ __PACKAGE__->register_method ({
                    type => 'integer',
                    title => 'Size',
                },
+               type => {
+                   type => 'string',
+                   title => 'Type',
+                   enum => ['replicated', 'erasure', 'unknown'],
+               },
                min_size => {
                    type => 'integer',
                    title => 'Min Size',
@@ -185,6 +190,17 @@ __PACKAGE__->register_method ({
                $d->{bytes_used} = $s->{bytes_used};
                $d->{percent_used} = $s->{percent_used};
            }
+
+           # Cephs numerical pool types are barely documented. Found the following in the Ceph
+           # codebase: https://github.com/ceph/ceph/blob/ff144995a849407c258bcb763daa3e03cfce5059/src/osd/osd_types.h#L1221-L1233
+           if ($e->{type} == 1) {
+               $d->{type} = 'replicated';
+           } elsif ($e->{type} == 3) {
+               $d->{type} = 'erasure';
+           } else {
+               # we should never get here, but better be safe
+               $d->{type} = 'unknown';
+           }
            push @$data, $d;
        }