mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-17 18:39:13 +00:00
api: ceph: create mon: factor out monmaptool command
so it's easier to re-use for a future variant. Reviewed-by: Dominik Csapak <d.csapak@proxmox.com> Tested-by: Dominik Csapak <d.csapak@proxmox.com> Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
parent
d3b899c144
commit
57951fc78b
@ -268,24 +268,24 @@ __PACKAGE__->register_method ({
|
|||||||
$cfg->{global}->{ms_bind_ipv6} = 'false' if $is_first_address;
|
$cfg->{global}->{ms_bind_ipv6} = 'false' if $is_first_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $monaddr = Net::IP::ip_is_ipv6($ip) ? "[$ip]" : $ip;
|
||||||
|
|
||||||
|
my $monmaptool_cmd = [
|
||||||
|
'monmaptool',
|
||||||
|
'--create',
|
||||||
|
'--clobber',
|
||||||
|
'--addv',
|
||||||
|
$monid,
|
||||||
|
"[v2:$monaddr:3300,v1:$monaddr:6789]",
|
||||||
|
'--print',
|
||||||
|
$monmap,
|
||||||
|
];
|
||||||
|
|
||||||
if (defined($rados)) { # we can only have a RADOS object if we have a monitor
|
if (defined($rados)) { # we can only have a RADOS object if we have a monitor
|
||||||
my $mapdata = $rados->mon_command({ prefix => 'mon getmap', format => 'plain' });
|
my $mapdata = $rados->mon_command({ prefix => 'mon getmap', format => 'plain' });
|
||||||
file_set_contents($monmap, $mapdata);
|
file_set_contents($monmap, $mapdata);
|
||||||
} else { # we need to create a monmap for the first monitor
|
} else { # we need to create a monmap for the first monitor
|
||||||
my $monaddr = $ip;
|
run_command($monmaptool_cmd);
|
||||||
if (Net::IP::ip_is_ipv6($ip)) {
|
|
||||||
$monaddr = "[$ip]";
|
|
||||||
}
|
|
||||||
run_command([
|
|
||||||
'monmaptool',
|
|
||||||
'--create',
|
|
||||||
'--clobber',
|
|
||||||
'--addv',
|
|
||||||
$monid,
|
|
||||||
"[v2:$monaddr:3300,v1:$monaddr:6789]",
|
|
||||||
'--print',
|
|
||||||
$monmap,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
run_command([
|
run_command([
|
||||||
|
Loading…
Reference in New Issue
Block a user