From fca1900c76ceb60d2a406d53be6b3f804f26adc7 Mon Sep 17 00:00:00 2001 From: Aaron Lauterer Date: Mon, 2 May 2022 14:36:24 +0200 Subject: [PATCH] api: ceph pools: add type to returned properties The osd dump already contains the pool type in numerical format. Signed-off-by: Aaron Lauterer Reviewed-by: Dominik Csapak Tested-by: Dominik Csapak --- PVE/API2/Ceph/Pools.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/PVE/API2/Ceph/Pools.pm b/PVE/API2/Ceph/Pools.pm index efdee360..70427277 100644 --- a/PVE/API2/Ceph/Pools.pm +++ b/PVE/API2/Ceph/Pools.pm @@ -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; } -- 2.39.2