[pve-devel] [PATCH installer 6/6] move vgrename check to other sanitychecks

Stoiko Ivanov s.ivanov at proxmox.com
Fri Nov 29 11:53:48 CET 2019


since the check runs at the same time as the one for existing ESPs and rpool
move the code there.

Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
 proxinstall | 120 ++++++++++++++++++++++++++--------------------------
 1 file changed, 60 insertions(+), 60 deletions(-)

diff --git a/proxinstall b/proxinstall
index 7eddafb..0135a7e 100755
--- a/proxinstall
+++ b/proxinstall
@@ -996,66 +996,6 @@ sub partition_bootable_disk {
     return ($os_size, $osdev, $efibootdev);
 }
 
-sub get_pv_list_from_vgname {
-    my ($vgname) = @_;
-
-    my $res;
-
-    my $parser = sub {
-	my $line = shift;
-	$line =~ s/^\s+//;
-	$line =~ s/\s+$//;
-	return if !$line;
-	my ($pv, $vg_uuid) = split(/\s+/, $line);
-
-	if (!defined($res->{$vg_uuid}->{pvs})) {
-	    $res->{$vg_uuid}->{pvs} = "$pv";
-	} else {
-	    $res->{$vg_uuid}->{pvs} .= ", $pv";
-	}
-    };
-    run_command("pvs --noheadings -o pv_name,vg_uuid -S vg_name='$vgname'", $parser, undef, 1);
-
-    return $res;
-}
-
-sub ask_existing_vg_rename_or_abort {
-    my ($vgname) = @_;
-
-    # this normally only happens if one put a disk with a PVE installation in
-    # this server and that disk is not the installation target.
-    my $duplicate_vgs = get_pv_list_from_vgname($vgname);
-    return if !$duplicate_vgs;
-
-    my $message = "Detected existing '$vgname' Volume Group(s)! Do you want to:\n";
-
-    for my $vg_uuid (keys %$duplicate_vgs) {
-	my $vg = $duplicate_vgs->{$vg_uuid};
-
-	# no high randomnes properties, but this is only for the cases where
-	# we either have multiple "$vgname" vgs from multiple old PVE disks, or
-	# we have a disk with both a "$vgname" and "$vgname-old"...
-	my $short_uid = sprintf "%08X", rand(0xffffffff);
-	$vg->{new_vgname} = "$vgname-OLD-$short_uid";
-
-	$message .= "rename VG backed by PV '$vg->{pvs}' to '$vg->{new_vgname}'\n";
-    }
-    $message .= "or cancel the installation?";
-
-    my $rename_vgs = sub {
-
-	for my $vg_uuid (keys %$duplicate_vgs) {
-	    my $vg = $duplicate_vgs->{$vg_uuid};
-	    my $new_vgname = $vg->{new_vgname};
-
-	    syscmd("vgrename $vg_uuid $new_vgname") == 0 ||
-		die "could not rename VG from '$vg->{pvs}' ($vg_uuid) to '$new_vgname'!\n";
-	}
-    };
-
-    ask_existing_diskconfig_or_abort($message, "existing volume group '$vgname'", $rename_vgs);
-}
-
 sub create_lvm_volumes {
     my ($lvmdev, $os_size, $swap_size) = @_;
 
@@ -3349,6 +3289,66 @@ sub create_hdsel_view {
     });
 }
 
+sub get_pv_list_from_vgname {
+    my ($vgname) = @_;
+
+    my $res;
+
+    my $parser = sub {
+	my $line = shift;
+	$line =~ s/^\s+//;
+	$line =~ s/\s+$//;
+	return if !$line;
+	my ($pv, $vg_uuid) = split(/\s+/, $line);
+
+	if (!defined($res->{$vg_uuid}->{pvs})) {
+	    $res->{$vg_uuid}->{pvs} = "$pv";
+	} else {
+	    $res->{$vg_uuid}->{pvs} .= ", $pv";
+	}
+    };
+    run_command("pvs --noheadings -o pv_name,vg_uuid -S vg_name='$vgname'", $parser, undef, 1);
+
+    return $res;
+}
+
+sub ask_existing_vg_rename_or_abort {
+    my ($vgname) = @_;
+
+    # this normally only happens if one put a disk with a PVE installation in
+    # this server and that disk is not the installation target.
+    my $duplicate_vgs = get_pv_list_from_vgname($vgname);
+    return if !$duplicate_vgs;
+
+    my $message = "Detected existing '$vgname' Volume Group(s)! Do you want to:\n";
+
+    for my $vg_uuid (keys %$duplicate_vgs) {
+	my $vg = $duplicate_vgs->{$vg_uuid};
+
+	# no high randomnes properties, but this is only for the cases where
+	# we either have multiple "$vgname" vgs from multiple old PVE disks, or
+	# we have a disk with both a "$vgname" and "$vgname-old"...
+	my $short_uid = sprintf "%08X", rand(0xffffffff);
+	$vg->{new_vgname} = "$vgname-OLD-$short_uid";
+
+	$message .= "rename VG backed by PV '$vg->{pvs}' to '$vg->{new_vgname}'\n";
+    }
+    $message .= "or cancel the installation?";
+
+    my $rename_vgs = sub {
+
+	for my $vg_uuid (keys %$duplicate_vgs) {
+	    my $vg = $duplicate_vgs->{$vg_uuid};
+	    my $new_vgname = $vg->{new_vgname};
+
+	    syscmd("vgrename $vg_uuid $new_vgname") == 0 ||
+		die "could not rename VG from '$vg->{pvs}' ($vg_uuid) to '$new_vgname'!\n";
+	}
+    };
+
+    ask_existing_diskconfig_or_abort($message, "existing volume group '$vgname'", $rename_vgs);
+}
+
 sub get_unused_bdevs {
     my ($used_disks) = @_;
 
-- 
2.20.1





More information about the pve-devel mailing list