public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Aaron Lauterer <a.lauterer@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager v2 follow up 2/4] api: ceph pools: add type to returned properties
Date: Mon,  2 May 2022 14:36:24 +0200	[thread overview]
Message-ID: <20220502123624.2449469-1-a.lauterer@proxmox.com> (raw)
In-Reply-To: <20220502080928.886800-2-a.lauterer@proxmox.com>

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

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
---
thanks to @Dominik we found a better place where the numerical pool
types are defined.

 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.30.2





  reply	other threads:[~2022-05-02 12:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-02  8:09 [pve-devel] [PATCH manager v2 1/4] ceph tools: set_pools: filter settings for erasure code pools Aaron Lauterer
2022-05-02  8:09 ` [pve-devel] [PATCH manager v2 2/4] api: ceph pools: add type to returned properties Aaron Lauterer
2022-05-02 12:36   ` Aaron Lauterer [this message]
2022-05-02  8:09 ` [pve-devel] [PATCH manager v2 3/4] ui: ceph pool edit: disable size and crush rule for erasure pools Aaron Lauterer
2022-05-02  8:09 ` [pve-devel] [PATCH manager v2 4/4] ui: ceph pools: add pool type column Aaron Lauterer
2022-05-02 13:25 ` [pve-devel] [PATCH manager v2 1/4] ceph tools: set_pools: filter settings for erasure code pools Dominik Csapak
2022-05-02 13:45 ` [pve-devel] applied-series: " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220502123624.2449469-1-a.lauterer@proxmox.com \
    --to=a.lauterer@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal