]> git.proxmox.com Git - pve-manager.git/commitdiff
api: ceph: create mon: factor out monmaptool command
authorFabian Ebner <f.ebner@proxmox.com>
Mon, 10 May 2021 12:18:19 +0000 (14:18 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 18 Jun 2021 15:13:04 +0000 (17:13 +0200)
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>
PVE/API2/Ceph/MON.pm

index b59b88f0f22d0f2ac424624faf1e82794480e931..7a72cd37c9b534c607204847cff027961ecc44a7 100644 (file)
@@ -268,24 +268,24 @@ __PACKAGE__->register_method ({
                        $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
                        my $mapdata = $rados->mon_command({ prefix => 'mon getmap', format => 'plain' });
                        file_set_contents($monmap, $mapdata);
                    } else { # we need to create a monmap for the first monitor
-                       my $monaddr = $ip;
-                       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($monmaptool_cmd);
                    }
 
                    run_command([