Functions to manage erasure code (EC) profiles: * add * remove * check if exists * get default prefixed name
Signed-off-by: Aaron Lauterer <[email protected]> --- 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; -- 2.30.2 _______________________________________________ pve-devel mailing list [email protected] https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
