mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-15 03:58:26 +00:00
ceph: move MGR API calls to API2/Ceph/MGR.pm
and adapt the paths Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
be7edba15d
commit
4fec2764f1
@ -21,6 +21,7 @@ use PVE::Tools qw(run_command file_get_contents file_set_contents);
|
||||
use PVE::API2::Ceph::OSD;
|
||||
use PVE::API2::Ceph::FS;
|
||||
use PVE::API2::Ceph::MDS;
|
||||
use PVE::API2::Ceph::MGR;
|
||||
use PVE::API2::Storage::Config;
|
||||
|
||||
use base qw(PVE::RESTHandler);
|
||||
@ -37,6 +38,11 @@ __PACKAGE__->register_method ({
|
||||
path => 'mds',
|
||||
});
|
||||
|
||||
__PACKAGE__->register_method ({
|
||||
subclass => "PVE::API2::Ceph::MGR",
|
||||
path => 'mgr',
|
||||
});
|
||||
|
||||
__PACKAGE__->register_method ({
|
||||
subclass => "PVE::API2::Ceph::FS",
|
||||
path => 'fs',
|
||||
@ -689,95 +695,6 @@ __PACKAGE__->register_method ({
|
||||
return $rpcenv->fork_worker('cephdestroymon', $monsection, $authuser, $worker);
|
||||
}});
|
||||
|
||||
__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::Ceph::Tools::check_ceph_installed('ceph_mgr');
|
||||
|
||||
PVE::Ceph::Tools::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::Ceph::Tools::get_config('long_rados_timeout'));
|
||||
|
||||
PVE::Ceph::Services::create_mgr($mgrid, $rados);
|
||||
};
|
||||
|
||||
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::Ceph::Tools::check_ceph_inited();
|
||||
|
||||
my $mgrid = $param->{id};
|
||||
|
||||
my $worker = sub {
|
||||
my $upid = shift;
|
||||
|
||||
PVE::Ceph::Services::destroy_mgr($mgrid);
|
||||
};
|
||||
|
||||
return $rpcenv->fork_worker('cephdestroymgr', "mgr.$mgrid", $authuser, $worker);
|
||||
}});
|
||||
|
||||
__PACKAGE__->register_method ({
|
||||
name => 'stop',
|
||||
path => 'stop',
|
||||
|
104
PVE/API2/Ceph/MGR.pm
Normal file
104
PVE/API2/Ceph/MGR.pm
Normal file
@ -0,0 +1,104 @@
|
||||
package PVE::API2::Ceph::MGR;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use File::Path;
|
||||
|
||||
use PVE::Ceph::Tools;
|
||||
use PVE::Ceph::Services;
|
||||
use PVE::JSONSchema qw(get_standard_option);
|
||||
use PVE::RADOS;
|
||||
use PVE::RPCEnvironment;
|
||||
use PVE::Tools qw(run_command);
|
||||
|
||||
use base qw(PVE::RESTHandler);
|
||||
|
||||
__PACKAGE__->register_method ({
|
||||
name => 'createmgr',
|
||||
path => '',
|
||||
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::Ceph::Tools::check_ceph_installed('ceph_mgr');
|
||||
|
||||
PVE::Ceph::Tools::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::Ceph::Tools::get_config('long_rados_timeout'));
|
||||
|
||||
PVE::Ceph::Services::create_mgr($mgrid, $rados);
|
||||
};
|
||||
|
||||
return $rpcenv->fork_worker('cephcreatemgr', "mgr.$mgrid", $authuser, $worker);
|
||||
}});
|
||||
|
||||
__PACKAGE__->register_method ({
|
||||
name => 'destroymgr',
|
||||
path => '{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::Ceph::Tools::check_ceph_inited();
|
||||
|
||||
my $mgrid = $param->{id};
|
||||
|
||||
my $worker = sub {
|
||||
my $upid = shift;
|
||||
|
||||
PVE::Ceph::Services::destroy_mgr($mgrid);
|
||||
};
|
||||
|
||||
return $rpcenv->fork_worker('cephdestroymgr', "mgr.$mgrid", $authuser, $worker);
|
||||
}});
|
@ -1,6 +1,7 @@
|
||||
include ../../../defines.mk
|
||||
|
||||
PERLSOURCE= \
|
||||
MGR.pm \
|
||||
OSD.pm \
|
||||
FS.pm \
|
||||
MDS.pm
|
||||
|
@ -21,6 +21,7 @@ use PVE::Ceph::Tools;
|
||||
use PVE::API2::Ceph;
|
||||
use PVE::API2::Ceph::FS;
|
||||
use PVE::API2::Ceph::MDS;
|
||||
use PVE::API2::Ceph::MGR;
|
||||
use PVE::API2::Ceph::OSD;
|
||||
|
||||
use PVE::CLIHandler;
|
||||
@ -193,8 +194,8 @@ our $cmddef = {
|
||||
createmon => { alias => 'mon create' },
|
||||
destroymon => { alias => 'mon destroy' },
|
||||
mgr => {
|
||||
create => [ 'PVE::API2::Ceph', 'createmgr', [], { node => $nodename }, $upid_exit],
|
||||
destroy => [ 'PVE::API2::Ceph', 'destroymgr', ['id'], { node => $nodename }, $upid_exit],
|
||||
create => [ 'PVE::API2::Ceph::MGR', 'createmgr', [], { node => $nodename }, $upid_exit],
|
||||
destroy => [ 'PVE::API2::Ceph::MGR', 'destroymgr', ['id'], { node => $nodename }, $upid_exit],
|
||||
},
|
||||
createmgr => { alias => 'mgr create' },
|
||||
destroymgr => { alias => 'mgr destroy' },
|
||||
|
Loading…
Reference in New Issue
Block a user