api: ceph: create mon: handle ms_bind_ipv* options more generally

mostly relevant to prepare support for IPv4/IPv6 dual stack mode as a special
case of the planned support for mutliple public networks.

As before, only set the false value when we are dealing with the first address,
but also be explicit about the IPv4 case as the defaults might change in the
future.

Then, when an address of a different type comes along later, set the relevant
bind option to true.

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:
Fabian Ebner 2021-05-10 14:18:18 +02:00 committed by Thomas Lamprecht
parent 6e96b07078
commit d3b899c144

View File

@ -259,6 +259,15 @@ __PACKAGE__->register_method ({
run_command(['chown', 'ceph:ceph', $mondir]);
my $is_first_address = !defined($rados);
if (Net::IP::ip_is_ipv6($ip)) {
$cfg->{global}->{ms_bind_ipv6} = 'true';
$cfg->{global}->{ms_bind_ipv4} = 'false' if $is_first_address;
} else {
$cfg->{global}->{ms_bind_ipv4} = 'true';
$cfg->{global}->{ms_bind_ipv6} = 'false' if $is_first_address;
}
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' });
file_set_contents($monmap, $mapdata);
@ -266,8 +275,6 @@ __PACKAGE__->register_method ({
my $monaddr = $ip;
if (Net::IP::ip_is_ipv6($ip)) {
$monaddr = "[$ip]";
$cfg->{global}->{ms_bind_ipv6} = 'true';
$cfg->{global}->{ms_bind_ipv4} = 'false';
}
run_command([
'monmaptool',