mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-17 04:08:51 +00:00
ceph: mon destroy: refactor removal assertions
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
ad475e25db
commit
3babcc1d52
@ -73,6 +73,19 @@ my $assert_mon_prerequisites = sub {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
my $assert_mon_can_remove = sub {
|
||||||
|
my ($monhash, $monlist, $monid, $mondir) = @_;
|
||||||
|
|
||||||
|
if (!(defined($monhash->{"mon.$monid"}) ||
|
||||||
|
grep { $_->{name} && $_->{name} eq $monid } @$monlist))
|
||||||
|
{
|
||||||
|
die "no such monitor id '$monid'\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
die "monitor filesystem '$mondir' does not exist on this node\n" if ! -d $mondir;
|
||||||
|
die "can't remove last monitor\n" if scalar(@$monlist) <= 1;
|
||||||
|
};
|
||||||
|
|
||||||
__PACKAGE__->register_method ({
|
__PACKAGE__->register_method ({
|
||||||
name => 'listmon',
|
name => 'listmon',
|
||||||
path => '',
|
path => '',
|
||||||
@ -306,16 +319,12 @@ __PACKAGE__->register_method ({
|
|||||||
my $rados = PVE::RADOS->new();
|
my $rados = PVE::RADOS->new();
|
||||||
my $monstat = $rados->mon_command({ prefix => 'mon_status' });
|
my $monstat = $rados->mon_command({ prefix => 'mon_status' });
|
||||||
my $monlist = $monstat->{monmap}->{mons};
|
my $monlist = $monstat->{monmap}->{mons};
|
||||||
|
my $monhash = PVE::Ceph::Services::get_services_info('mon', $cfg, $rados);
|
||||||
die "no such monitor id '$monid'\n"
|
|
||||||
if !defined($cfg->{$monsection});
|
|
||||||
|
|
||||||
my $ccname = PVE::Ceph::Tools::get_config('ccname');
|
my $ccname = PVE::Ceph::Tools::get_config('ccname');
|
||||||
|
|
||||||
my $mondir = "/var/lib/ceph/mon/$ccname-$monid";
|
my $mondir = "/var/lib/ceph/mon/$ccname-$monid";
|
||||||
-d $mondir || die "monitor filesystem '$mondir' does not exist on this node\n";
|
|
||||||
|
|
||||||
die "can't remove last monitor\n" if scalar(@$monlist) <= 1;
|
$assert_mon_can_remove->($monhash, $monlist, $monid, $mondir);
|
||||||
|
|
||||||
my $worker = sub {
|
my $worker = sub {
|
||||||
my $upid = shift;
|
my $upid = shift;
|
||||||
|
Loading…
Reference in New Issue
Block a user