[pve-devel] [PATCH manager 1/3] ceph: add service restart api call

Dominik Csapak d.csapak at proxmox.com
Fri Nov 23 11:46:43 CET 2018


like start/stop but for restart, this makes maintenance a bit easier

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 PVE/API2/Ceph.pm | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm
index 0fc95ab0..374d83b4 100644
--- a/PVE/API2/Ceph.pm
+++ b/PVE/API2/Ceph.pm
@@ -1448,6 +1448,56 @@ __PACKAGE__->register_method ({
     }});
 
 __PACKAGE__->register_method ({
+    name => 'restart',
+    path => 'restart',
+    method => 'POST',
+    description => "Restart ceph services.",
+    proxyto => 'node',
+    protected => 1,
+    permissions => {
+	check => ['perm', '/', [ 'Sys.Modify' ]],
+    },
+    parameters => {
+	additionalProperties => 0,
+	properties => {
+	    node => get_standard_option('pve-node'),
+	    service => {
+		description => 'Ceph service name.',
+		type => 'string',
+		optional => 1,
+		pattern => '(mon|mds|osd|mgr)\.[A-Za-z0-9\-]{1,32}',
+	    },
+	},
+    },
+    returns => { type => 'string' },
+    code => sub {
+	my ($param) = @_;
+
+	my $rpcenv = PVE::RPCEnvironment::get();
+
+	my $authuser = $rpcenv->get_user();
+
+	PVE::CephTools::check_ceph_inited();
+
+	my $cfg = PVE::CephTools::parse_ceph_config();
+	scalar(keys %$cfg) || die "no configuration\n";
+
+	my $worker = sub {
+	    my $upid = shift;
+
+	    my $cmd = ['restart'];
+	    if ($param->{service}) {
+		push @$cmd, $param->{service};
+	    }
+
+	    PVE::CephTools::ceph_service_cmd(@$cmd);
+	};
+
+	return $rpcenv->fork_worker('srvrestart', $param->{service} || 'ceph',
+				    $authuser, $worker);
+    }});
+
+__PACKAGE__->register_method ({
     name => 'status',
     path => 'status',
     method => 'GET',
-- 
2.11.0





More information about the pve-devel mailing list