[pve-devel] [PATCH manager 2/5] ceph tools: add erasure code management functions

Dominik Csapak d.csapak at proxmox.com
Thu Apr 28 16:19:48 CEST 2022


imho all functions that use a PVE::RADOS object here should take one optionally
(like the rest of the functions in this file, e.g. create_pool)

On 4/28/22 13:58, Aaron Lauterer wrote:
> Functions to manage erasure code (EC) profiles:
> * add
> * remove
> * check if exists
> * get default prefixed name
> 
> Signed-off-by: Aaron Lauterer <a.lauterer at proxmox.com>
> ---
>   PVE/Ceph/Tools.pm | 49 +++++++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 49 insertions(+)
> 
> diff --git a/PVE/Ceph/Tools.pm b/PVE/Ceph/Tools.pm
> index 36d7788a..0c75df0e 100644
> --- a/PVE/Ceph/Tools.pm
> +++ b/PVE/Ceph/Tools.pm
> @@ -531,4 +531,53 @@ sub ceph_cluster_status {
>       return $status;
>   }
>   
> +sub ecprofile_exists {
> +    my ($name) = @_;
> +
> +    my $rados = PVE::RADOS->new();
> +    my $res = $rados->mon_command({ prefix => 'osd erasure-code-profile ls' });
> +
> +    my $profiles = { map { $_ => 1 } @$res };
> +    return $profiles->{$name};
> +}
> +
> +sub create_ecprofile {
> +    my ($name, $k, $m, $failure_domain, $device_class) = @_;
> +
> +    $failure_domain = 'host' if !$failure_domain;
> +
> +    my $profile = [
> +	"crush-failure-domain=${failure_domain}",
> +	"k=${k}",
> +	"m=${m}",
> +    ];
> +
> +    push(@$profile, "crush-device-class=${device_class}") if $device_class;
> +
> +    my $rados = PVE::RADOS->new();
> +    $rados->mon_command({
> +	prefix => 'osd erasure-code-profile set',
> +	name => $name,
> +	profile => $profile,
> +    });
> +}
> +
> +sub destroy_ecprofile {
> +    my ($profile) = @_;
> +
> +    my $rados = PVE::RADOS->new();
> +    my $command = {
> +	prefix => 'osd erasure-code-profile rm',
> +	name => $profile,
> +	format => 'plain',
> +    };
> +    return $rados->mon_command($command);
> +}
> +
> +sub get_ecprofile_name {
> +    my ($name) = @_;
> +    return "pve_ec_${name}";
> +}
> +
> +
>   1;






More information about the pve-devel mailing list