From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 2248860AB2 for ; Mon, 19 Oct 2020 12:40:10 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1316C2B76C for ; Mon, 19 Oct 2020 12:39:40 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id A420F2B74C for ; Mon, 19 Oct 2020 12:39:38 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 6CC8943126 for ; Mon, 19 Oct 2020 12:39:38 +0200 (CEST) From: Alwin Antreich To: pve-devel@lists.proxmox.com Date: Mon, 19 Oct 2020 12:39:31 +0200 Message-Id: <20201019103934.1484472-2-a.antreich@proxmox.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201019103934.1484472-1-a.antreich@proxmox.com> References: <20201019103934.1484472-1-a.antreich@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.000 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH manager v2 2/5] ceph: allow to alter pool settings X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Oct 2020 10:40:10 -0000 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 --- 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