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

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Jul 26 10:53:35 CEST 2017


The s/mgrid/id/ renaming was only done partially, see minor comments
below.
Once fixed the rest looks good for me now.

On 07/26/2017 10:42 AM, Dominik Csapak wrote:
> 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 v1:
> * corrected the id regex
> * optimized the id assignment and dropped the unnecessary die
> * removed the hunk which belonged in patch 1
> * renamed the parameter of the destroymgr call to id to be consistent
> * corrected the description
> 
>   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 9b9b7fec..a499bd3a 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/{mgrid}',

s/mgrid/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->{mgrid};

s/$param->{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..4f4a7708 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', ['mgrid'], { node => $nodename }, $upid_exit],

s/mgrid/id/

>       start => [ 'PVE::API2::Ceph', 'start', ['service'], { node => $nodename }, $upid_exit],
>       stop => [ 'PVE::API2::Ceph', 'stop', ['service'], { node => $nodename }, $upid_exit],
>       install => [ __PACKAGE__, 'install', [] ],
> 





More information about the pve-devel mailing list