[pve-devel] [PATCH manager v3 2/3] pveceph: add createmgr/destroymgr commands

Dominik Csapak d.csapak at proxmox.com
Wed Jul 26 11:11:52 CEST 2017


this patch adds the create-/destroymgr commands to the api and pveceph,
so that advanced users can split monitor and manager daemons

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
changes from v2:
* changed the remaining instances of 'mgrid' to 'id' for destroymgr

 PVE/API2/Ceph.pm   | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 PVE/CLI/pveceph.pm |  2 ++
 2 files changed, 89 insertions(+)

diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm
index 9bcac311..13b156f6 100644
--- a/PVE/API2/Ceph.pm
+++ b/PVE/API2/Ceph.pm
@@ -1140,6 +1140,93 @@ __PACKAGE__->register_method ({
     }});
 
 __PACKAGE__->register_method ({
+    name => 'createmgr',
+    path => 'mgr',
+    method => 'POST',
+    description => "Create Ceph Manager",
+    proxyto => 'node',
+    protected => 1,
+    permissions => {
+	check => ['perm', '/', [ 'Sys.Modify' ]],
+    },
+    parameters => {
+	additionalProperties => 0,
+	properties => {
+	    node => get_standard_option('pve-node'),
+	    id => {
+		type => 'string',
+		optional => 1,
+		pattern => '[a-zA-Z0-9]([a-zA-Z0-9\-]*[a-zA-Z0-9])?',
+		description => "The ID for the manager, when omitted the same as the nodename",
+	    },
+	},
+    },
+    returns => { type => 'string' },
+    code => sub {
+	my ($param) = @_;
+
+	PVE::CephTools::check_ceph_inited();
+
+	my $rpcenv = PVE::RPCEnvironment::get();
+
+	my $authuser = $rpcenv->get_user();
+
+	my $mgrid = $param->{id} // $param->{node};
+
+	my $worker = sub  {
+	    my $upid = shift;
+
+	    my $rados = PVE::RADOS->new(timeout => PVE::CephTools::get_config('long_rados_timeout'));
+
+	    $create_mgr->($rados, $mgrid);
+	};
+
+	return $rpcenv->fork_worker('cephcreatemgr', "mgr.$mgrid", $authuser, $worker);
+    }});
+
+__PACKAGE__->register_method ({
+    name => 'destroymgr',
+    path => 'mgr/{id}',
+    method => 'DELETE',
+    description => "Destroy Ceph Manager.",
+    proxyto => 'node',
+    protected => 1,
+    permissions => {
+	check => ['perm', '/', [ 'Sys.Modify' ]],
+    },
+    parameters => {
+	additionalProperties => 0,
+	properties => {
+	    node => get_standard_option('pve-node'),
+	    id => {
+		description => 'The ID of the manager',
+		type => 'string',
+		pattern => '[a-zA-Z0-9]([a-zA-Z0-9\-]*[a-zA-Z0-9])?',
+	    },
+	},
+    },
+    returns => { type => 'string' },
+    code => sub {
+	my ($param) = @_;
+
+	my $rpcenv = PVE::RPCEnvironment::get();
+
+	my $authuser = $rpcenv->get_user();
+
+	PVE::CephTools::check_ceph_inited();
+
+	my $mgrid = $param->{id};
+
+	my $worker = sub {
+	    my $upid = shift;
+
+	    $destroy_mgr->($mgrid);
+	};
+
+	return $rpcenv->fork_worker('cephdestroymgr', "mgr.$mgrid",  $authuser, $worker);
+    }});
+
+__PACKAGE__->register_method ({
     name => 'stop',
     path => 'stop',
     method => 'POST',
diff --git a/PVE/CLI/pveceph.pm b/PVE/CLI/pveceph.pm
index ee34cfc5..422ac709 100755
--- a/PVE/CLI/pveceph.pm
+++ b/PVE/CLI/pveceph.pm
@@ -170,6 +170,8 @@ our $cmddef = {
     destroyosd => [ 'PVE::API2::CephOSD', 'destroyosd', ['osdid'], { node => $nodename }, $upid_exit],
     createmon => [ 'PVE::API2::Ceph', 'createmon', [], { node => $nodename }, $upid_exit],
     destroymon => [ 'PVE::API2::Ceph', 'destroymon', ['monid'], { node => $nodename }, $upid_exit],
+    createmgr => [ 'PVE::API2::Ceph', 'createmgr', [], { node => $nodename }, $upid_exit],
+    destroymgr => [ 'PVE::API2::Ceph', 'destroymgr', ['id'], { node => $nodename }, $upid_exit],
     start => [ 'PVE::API2::Ceph', 'start', ['service'], { node => $nodename }, $upid_exit],
     stop => [ 'PVE::API2::Ceph', 'stop', ['service'], { node => $nodename }, $upid_exit],
     install => [ __PACKAGE__, 'install', [] ],
-- 
2.11.0





More information about the pve-devel mailing list