From d3b899c144dcbf271ad94c5946a80a5df447bf5e Mon Sep 17 00:00:00 2001 From: Fabian Ebner Date: Mon, 10 May 2021 14:18:18 +0200 Subject: [PATCH] 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 Tested-by: Dominik Csapak Signed-off-by: Fabian Ebner --- PVE/API2/Ceph/MON.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/PVE/API2/Ceph/MON.pm b/PVE/API2/Ceph/MON.pm index c759fdc8..b59b88f0 100644 --- a/PVE/API2/Ceph/MON.pm +++ b/PVE/API2/Ceph/MON.pm @@ -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',