]> git.proxmox.com Git - pve-manager.git/blobdiff - PVE/API2/Ceph/Pools.pm
ceph pools create: remove crush_rule for ec pool data
[pve-manager.git] / PVE / API2 / Ceph / Pools.pm
index 4e28453cc23140f70f3b42c440d270f889ca195d..9c3b88844d6caa1e8d3c9c1a8f325ba671f1231b 100644 (file)
@@ -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;
        }
 
@@ -381,14 +397,14 @@ __PACKAGE__->register_method ({
        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.",
+               description => "Configure VM and CT storage using the new pool.",
                type => 'boolean',
                optional => 1,
+               default => "0; for erasure coded pools: 1",
            },
            'erasure-coding' => {
-               description => "Create an erasure coded pool for RBD with an ".
-                               "accompaning replicated pool for metadata storage.",
+               description => "Create an erasure coded pool for RBD with an"
+                   ." accompaning replicated pool for metadata storage.",
                type => 'string',
                format => $ec_format,
                optional => 1,
@@ -409,13 +425,16 @@ __PACKAGE__->register_method ({
 
        my $rpcenv = PVE::RPCEnvironment::get();
        my $user = $rpcenv->get_user();
-
        # Ceph uses target_size_bytes
        if (defined($param->{'target_size'})) {
            my $target_sizestr = extract_param($param, 'target_size');
            $param->{target_size_bytes} = PVE::JSONSchema::parse_size($target_sizestr);
        }
 
+       my $rados = PVE::RADOS->new();
+       my $ec = ec_parse_and_check(extract_param($param, 'erasure-coding'), $rados);
+       $add_storages = 1 if $ec && !defined($add_storages);
+
        if ($add_storages) {
            $rpcenv->check($user, '/storage', ['Datastore.Allocate']);
            die "pool name contains characters which are illegal for storage naming\n"
@@ -429,10 +448,6 @@ __PACKAGE__->register_method ({
        $param->{application} //= 'rbd';
        $param->{pg_autoscale_mode} //= 'warn';
 
-       my $rados = PVE::RADOS->new();
-
-       my $ec = ec_parse_and_check(extract_param($param, 'erasure-coding'), $rados);
-
        my $worker = sub {
            # reopen with longer timeout
            $rados = PVE::RADOS->new(timeout => PVE::Ceph::Tools::get_config('long_rados_timeout'));
@@ -459,6 +474,7 @@ __PACKAGE__->register_method ({
                $ec_data_param->{erasure_code_profile} = $ec->{profile};
                delete $ec_data_param->{size};
                delete $ec_data_param->{min_size};
+               delete $ec_data_param->{crush_rule};
 
                # metadata pool should be ok with 32 PGs
                $param->{pg_num} = 32;