From b7701301a863713ff5dc09ee0ed1d3d00880a023 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Wed, 10 Jul 2019 15:13:51 +0200 Subject: [PATCH] api/ceph: add osd scrub api call can be called to (deep) scrub a specific osd Signed-off-by: Dominik Csapak --- PVE/API2/Ceph/OSD.pm | 45 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/PVE/API2/Ceph/OSD.pm b/PVE/API2/Ceph/OSD.pm index 85197107..0582d538 100644 --- a/PVE/API2/Ceph/OSD.pm +++ b/PVE/API2/Ceph/OSD.pm @@ -650,4 +650,49 @@ __PACKAGE__->register_method ({ return undef; }}); +__PACKAGE__->register_method ({ + name => 'scrub', + path => '{osdid}/scrub', + method => 'POST', + description => "Instruct the OSD to scrub.", + proxyto => 'node', + protected => 1, + permissions => { + check => ['perm', '/', [ 'Sys.Modify' ]], + }, + parameters => { + additionalProperties => 0, + properties => { + node => get_standard_option('pve-node'), + osdid => { + description => 'OSD ID', + type => 'integer', + }, + deep => { + description => 'If set, instructs a deep scrub instead of a normal one.', + type => 'boolean', + optional => 1, + default => 0, + }, + }, + }, + returns => { type => "null" }, + code => sub { + my ($param) = @_; + + PVE::Ceph::Tools::check_ceph_inited(); + + my $osdid = $param->{osdid}; + my $deep = $param->{deep} // 0; + + my $rados = PVE::RADOS->new(); + + my $osdstat = &$get_osd_status($rados, $osdid); # osd exists? + my $prefix = $deep ? 'osd deep-scrub' : 'osd scrub'; + + $rados->mon_command({ prefix => $prefix, who => $osdid }); + + return undef; + }}); + 1;