From efa17e3c6d9a5e8338be5726f8f5ab998fcde106 Mon Sep 17 00:00:00 2001 From: Pascal Terjan Date: Fri, 18 Sep 2009 10:20:02 +0000 Subject: suggest a LVM name and refuse empty or existing one (#53769) --- perl-install/diskdrake/interactive.pm | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'perl-install/diskdrake') diff --git a/perl-install/diskdrake/interactive.pm b/perl-install/diskdrake/interactive.pm index 56ff98934..9aa427dad 100644 --- a/perl-install/diskdrake/interactive.pm +++ b/perl-install/diskdrake/interactive.pm @@ -883,6 +883,9 @@ sub Add2RAID { sub Add2LVM { my ($in, $hd, $part, $all_hds) = @_; my $lvms = $all_hds->{lvms}; + my @lvm_names = map { $_->{VG_name} } @$lvms; + use Data::Dumper; + print Dumper(@lvm_names); write_partitions($in, $_) or return foreach isRAID($part) ? @{$all_hds->{hds}} : $hd; my $lvm = $in->ask_from_listf_(N("Add to LVM"), N("Choose an existing LVM to add to"), @@ -891,8 +894,23 @@ sub Add2LVM { require lvm; if (!ref $lvm) { # create new lvm - # FIXME: when mdv2006 is out: remove the question mark from the dialog title - my $name = $in->ask_from_entry(N("LVM name?"), N("LVM name?")) or return; + my $n = 0; + while (member("vg$n", @lvm_names)) { + $n++; + } + + my $name = "vg$n"; + $in->ask_from_({ title => N("LVM name"), + messages => N("Enter a name for the new LVM volume group"), + focus_first => 1, + ok_disabled => sub { !$name }, + validate => sub { + member($name, @lvm_names) or return 1; + $in->ask_warn(N("Error"), N('"%s" already exists', $name)); + return 0; + } }, + [{label=>N("LVM name"),val=> \$name}]) or return; + $lvm = new lvm($name); push @$lvms, $lvm; } -- cgit v1.2.1