On 6/18/19 3:42 PM, Dominik Csapak wrote: > Signed-off-by: Dominik Csapak <d.csa...@proxmox.com> > --- > PVE/API2/Ceph/MON.pm | 19 +++++++++++++------ > 1 file changed, 13 insertions(+), 6 deletions(-) > > diff --git a/PVE/API2/Ceph/MON.pm b/PVE/API2/Ceph/MON.pm > index 832a275e..2d116bb0 100644 > --- a/PVE/API2/Ceph/MON.pm > +++ b/PVE/API2/Ceph/MON.pm > @@ -73,6 +73,17 @@ my $assert_mon_prerequisites = sub { > } > }; > > +my $assert_mon_can_remove = sub { > + my ($monhash, $monlist, $monid) = @_; > + > + die "no such monitor id '$monid'\n" > + if !defined($monhash->{"mon.$monid"}) && > + !grep { $_->{name} && $_->{name} eq $monid } @$monlist;
indentation error above, may apply De Morgan's laws and do a "real" if (not post if). > + > + -d $mondir || die "monitor filesystem '$mondir' does not exist on this > node\n"; copied from below, but maybe for consistency: 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 ({ > name => 'listmon', > path => '', > @@ -307,16 +318,12 @@ __PACKAGE__->register_method ({ > my $rados = PVE::RADOS->new(); > my $monstat = $rados->mon_command({ prefix => 'mon_status' }); > my $monlist = $monstat->{monmap}->{mons}; > - > - die "no such monitor id '$monid'\n" > - if !defined($cfg->{$monsection}); > + my $monhash = PVE::Ceph::Services::get_services_info('mon', $cfg, > $rados); > > my $ccname = PVE::Ceph::Tools::get_config('ccname'); > - > 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); > > my $worker = sub { > my $upid = shift; > _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel