public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Alwin Antreich <a.antreich@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager v2 2/5] ceph: allow to alter pool settings
Date: Mon, 19 Oct 2020 12:39:31 +0200	[thread overview]
Message-ID: <20201019103934.1484472-2-a.antreich@proxmox.com> (raw)
In-Reply-To: <20201019103934.1484472-1-a.antreich@proxmox.com>

after creation, so that users don't need to go the ceph tooling route.
Separate common pool options to reuse them in other places.

Signed-off-by: Alwin Antreich <a.antreich@proxmox.com>
---
 PVE/API2/Ceph.pm   | 98 ++++++++++++++++++++++++++++++++++++++++++++++
 PVE/CLI/pveceph.pm |  1 +
 2 files changed, 99 insertions(+)

diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm
index 48d0484f..7cdbdccd 100644
--- a/PVE/API2/Ceph.pm
+++ b/PVE/API2/Ceph.pm
@@ -674,6 +674,63 @@ __PACKAGE__->register_method ({
 	return $data;
     }});
 
+
+my $ceph_pool_common_options = sub {
+    my ($nodefault) = shift;
+    my $options = {
+	name => {
+	    description => "The name of the pool. It must be unique.",
+	    type => 'string',
+	},
+	size => {
+	    description => 'Number of replicas per object',
+	    type => 'integer',
+	    default => 3,
+	    optional => 1,
+	    minimum => 1,
+	    maximum => 7,
+	},
+	min_size => {
+	    description => 'Minimum number of replicas per object',
+	    type => 'integer',
+	    default => 2,
+	    optional => 1,
+	    minimum => 1,
+	    maximum => 7,
+	},
+	pg_num => {
+	    description => "Number of placement groups.",
+	    type => 'integer',
+	    default => 128,
+	    optional => 1,
+	    minimum => 8,
+	    maximum => 32768,
+	},
+	crush_rule => {
+	    description => "The rule to use for mapping object placement in the cluster.",
+	    type => 'string',
+	    optional => 1,
+	},
+	application => {
+	    description => "The application of the pool.",
+	    default => 'rbd',
+	    type => 'string',
+	    enum => ['rbd', 'cephfs', 'rgw'],
+	    optional => 1,
+	},
+    };
+
+    if (!$nodefault) {
+	return $options;
+    } else {
+	foreach my $key (keys %$options) {
+	    delete $options->{$key}->{default} if defined($options->{$key}->{default});
+	}
+	return $options;
+    }
+};
+
+
 __PACKAGE__->register_method ({
     name => 'createpool',
     path => 'pools',
@@ -974,6 +1031,47 @@ __PACKAGE__->register_method ({
     }});
 
 
+__PACKAGE__->register_method ({
+    name => 'setpool',
+    path => 'pools/{name}',
+    method => 'PUT',
+    description => "Change POOL settings",
+    proxyto => 'node',
+    protected => 1,
+    permissions => {
+	check => ['perm', '/', [ 'Sys.Modify' ]],
+    },
+    parameters => {
+	additionalProperties => 0,
+	properties => {
+	    node => get_standard_option('pve-node'),
+	    %{ $ceph_pool_common_options->('nodefault') },
+	},
+    },
+    returns => { type => 'string' },
+    code => sub {
+	my ($param) = @_;
+
+	PVE::Ceph::Tools::check_ceph_configured();
+
+	my $rpcenv = PVE::RPCEnvironment::get();
+	my $authuser = $rpcenv->get_user();
+
+	my $pool = $param->{name};
+	my $ceph_param = \%$param;
+	for my $item ('name', 'node') {
+	    # not ceph parameters
+	    delete $ceph_param->{$item};
+	}
+
+	my $worker = sub {
+	    PVE::Ceph::Tools::set_pool($pool, $ceph_param);
+	};
+
+	return $rpcenv->fork_worker('cephsetpool', $pool,  $authuser, $worker);
+    }});
+
+
 __PACKAGE__->register_method ({
     name => 'crush',
     path => 'crush',
diff --git a/PVE/CLI/pveceph.pm b/PVE/CLI/pveceph.pm
index af14cbc0..b8420a1d 100755
--- a/PVE/CLI/pveceph.pm
+++ b/PVE/CLI/pveceph.pm
@@ -198,6 +198,7 @@ our $cmddef = {
 	}, $PVE::RESTHandler::standard_output_options],
 	create => [ 'PVE::API2::Ceph', 'createpool', ['name'], { node => $nodename }],
 	destroy => [ 'PVE::API2::Ceph', 'destroypool', ['name'], { node => $nodename } ],
+	set => [ 'PVE::API2::Ceph', 'setpool', ['name'], { node => $nodename } ],
     },
     lspools => { alias => 'pool ls' },
     createpool => { alias => 'pool create' },
-- 
2.27.0





  reply	other threads:[~2020-10-19 10:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-19 10:39 [pve-devel] [PATCH manager v2 1/5] ceph: split out pool set into own method Alwin Antreich
2020-10-19 10:39 ` Alwin Antreich [this message]
2020-10-19 10:39 ` [pve-devel] [PATCH manager v2 3/5] ceph: use pool common options pool create Alwin Antreich
2020-10-19 10:39 ` [pve-devel] [PATCH manager v2 4/5] ceph: add pg_autoscale_mode to " Alwin Antreich
2020-10-19 10:39 ` [pve-devel] [PATCH manager v2 5/5] ceph: gui: add autoscale mode " Alwin Antreich
2020-10-22 16:52 ` [pve-devel] applied-series: [PATCH manager v2 1/5] ceph: split out pool set into own method 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=20201019103934.1484472-2-a.antreich@proxmox.com \
    --to=a.antreich@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