From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager] pveceph: add ecpool create wrapper for the CLI
Date: Fri, 29 Apr 2022 09:39:30 +0200 [thread overview]
Message-ID: <20220429073930.727465-1-d.csapak@proxmox.com> (raw)
that exposes the ec options as seperate parameters instead of a format string
(for convenience). I made the ceph_pool_common_options and ec_format
public so that we can reuse them for that
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
@Thomas, because you suggested something like that, but it seems a bit
out of place to me, and giving the options as property-string is not too
bad, e.g.
pveceph pool create poolname --erasure-coding k=2,m2
vs
pveceph ecpool create poolname 2 2
PVE/API2/Ceph/Pools.pm | 14 +++++++++-----
PVE/CLI/pveceph.pm | 39 ++++++++++++++++++++++++++++++++++++++-
2 files changed, 47 insertions(+), 6 deletions(-)
diff --git a/PVE/API2/Ceph/Pools.pm b/PVE/API2/Ceph/Pools.pm
index eeb81d65..7cf16b39 100644
--- a/PVE/API2/Ceph/Pools.pm
+++ b/PVE/API2/Ceph/Pools.pm
@@ -193,7 +193,7 @@ __PACKAGE__->register_method ({
}});
-my $ceph_pool_common_options = sub {
+sub ceph_pool_common_options {
my ($nodefault) = shift;
my $options = {
name => {
@@ -276,7 +276,7 @@ my $ceph_pool_common_options = sub {
delete $options->{$_}->{default} for keys %$options;
}
return $options;
-};
+}
my $add_storage = sub {
@@ -352,6 +352,10 @@ my $ec_format = {
},
};
+sub get_ec_format {
+ return $ec_format;
+}
+
sub ec_parse_and_check {
my ($property, $rados) = @_;
return if !$property;
@@ -390,7 +394,7 @@ __PACKAGE__->register_method ({
format => $ec_format,
optional => 1,
},
- %{ $ceph_pool_common_options->() },
+ %{ ceph_pool_common_options() },
},
},
returns => { type => 'string' },
@@ -598,7 +602,7 @@ __PACKAGE__->register_method ({
additionalProperties => 0,
properties => {
node => get_standard_option('pve-node'),
- %{ $ceph_pool_common_options->('nodefault') },
+ %{ ceph_pool_common_options('nodefault') },
},
},
returns => { type => 'string' },
@@ -671,7 +675,7 @@ __PACKAGE__->register_method ({
application_list => { type => 'array', title => 'Application', optional => 1 },
statistics => { type => 'object', title => 'Statistics', optional => 1 },
autoscale_status => { type => 'object', title => 'Autoscale Status', optional => 1 },
- %{ $ceph_pool_common_options->() },
+ %{ ceph_pool_common_options() },
},
},
code => sub {
diff --git a/PVE/CLI/pveceph.pm b/PVE/CLI/pveceph.pm
index 995cfcd5..7fd110fd 100755
--- a/PVE/CLI/pveceph.pm
+++ b/PVE/CLI/pveceph.pm
@@ -15,7 +15,7 @@ use PVE::Cluster;
use PVE::INotify;
use PVE::RPCEnvironment;
use PVE::Storage;
-use PVE::Tools qw(run_command);
+use PVE::Tools qw(run_command extract_param);
use PVE::JSONSchema qw(get_standard_option);
use PVE::Ceph::Tools;
use PVE::Ceph::Services;
@@ -340,8 +340,45 @@ __PACKAGE__->register_method ({
return $rpcenv->fork_worker('cephdestroyfs', $fs_name, $user, $worker);
}});
+__PACKAGE__->register_method ({
+ name => 'ecpoolcreate',
+ path => 'ecpoolcreate',
+ method => 'POST',
+ description => "Create an erasure-coded pool",
+ parameters => {
+ additionalProperties => 0,
+ properties => {
+ node => get_standard_option('pve-node'),
+ add_storages => {
+ description => "Configure VM and CT storage using the new pool. ".
+ "Always enabled for erasure coded pools.",
+ type => 'boolean',
+ optional => 1,
+ },
+ %{ PVE::API2::Ceph::Pools::ceph_pool_common_options() },
+ %{ PVE::API2::Ceph::Pools::get_ec_format() },
+ },
+ },
+ returns => { type => 'string' },
+ code => sub {
+ my ($param) = @_;
+
+ my $ec_format = PVE::API2::Ceph::Pools::get_ec_format();
+ my $ec_params = {};
+ for my $k (keys %$ec_format) {
+ $ec_params->{$k} = extract_param($param, $k);
+ }
+
+ $param->{'erasure-coding'} = PVE::JSONSchema::print_property_string($ec_params, $ec_format);
+
+ return PVE::API2::Ceph::Pools->createpool($param);
+ }});
+
our $cmddef = {
init => [ 'PVE::API2::Ceph', 'init', [], { node => $nodename } ],
+ ecpool => {
+ create => [ __PACKAGE__, 'ecpoolcreate', ['name', 'k', 'm'], { node => $nodename }, $upid_exit],
+ },
pool => {
ls => [ 'PVE::API2::Ceph::Pools', 'lspools', [], { node => $nodename }, sub {
my ($data, $schema, $options) = @_;
--
2.30.2
next reply other threads:[~2022-04-29 7:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-29 7:39 Dominik Csapak [this message]
2022-04-29 7:43 ` 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=20220429073930.727465-1-d.csapak@proxmox.com \
--to=d.csapak@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.