[pve-devel] [PATCH manager v2 2/4] api: ceph pools: add type to returned properties

Aaron Lauterer a.lauterer at proxmox.com
Mon May 2 10:09:26 CEST 2022


The osd dump already contains the pool type in numerical format.

Signed-off-by: Aaron Lauterer <a.lauterer at proxmox.com>
---
changes since v1:
add link to ceph codebase where numerical pool types are defined for
reference

 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..6931d5f6 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/22c402b84e508af396252c5875253c8742b732e6/qa/tasks/ceph_manager.py#L196-L198
+	    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.30.2






More information about the pve-devel mailing list