Fail if LV, PV or VG no longer exists

This commit is contained in:
Jamie Cameron
2011-08-09 00:06:36 -07:00
parent 7d1ca7c3d1
commit 4d05e35e18
7 changed files with 26 additions and 7 deletions

View File

@@ -4,11 +4,13 @@
require './lvm-lib.pl';
&ReadParse();
($vg) = grep { $_->{'name'} eq $in{'vg'} } &list_volume_groups();
$vg || &error($text{'vg_egone'});
@lvs = &list_logical_volumes($in{'vg'});
$vgdesc = &text('lv_vg', $vg->{'name'});
if ($in{'lv'}) {
($lv) = grep { $_->{'name'} eq $in{'lv'} } @lvs;
$lv || &error($text{'lv_egone'});
&ui_print_header($vgdesc, $lv->{'is_snap'} ? $text{'lv_edit_snap'}
: $text{'lv_edit'}, "");
@stat = &device_status($lv->{'device'});

View File

@@ -5,11 +5,13 @@
require './lvm-lib.pl';
&ReadParse();
($vg) = grep { $_->{'name'} eq $in{'vg'} } &list_volume_groups();
$vg || &error($text{'vg_egone'});
$vgdesc = &text('pv_vg', $vg->{'name'});
if ($in{'pv'}) {
@pvs = &list_physical_volumes($in{'vg'});
($pv) = grep { $_->{'name'} eq $in{'pv'} } @pvs;
$pv || &error($text{'pv_egone'});
&ui_print_header($vgdesc, $text{'pv_edit'}, "");
}
else {

View File

@@ -7,6 +7,7 @@ require './lvm-lib.pl';
if ($in{'vg'}) {
($vg) = grep { $_->{'name'} eq $in{'vg'} } &list_volume_groups();
$vg || &error($text{'vg_egone'});
&ui_print_header(undef, $text{'vg_edit'}, "");
}
else {

View File

@@ -106,6 +106,7 @@ lv_free=Free percentage
lv_freedisk=Free space
lv_pvs=Physical volumes allocated
lv_snapusage=Snapshot use percentage
lv_egone=Logical volume no longer exists!
mkfs_title=Create Filesystem
mkfs_desc=This form allows you to build a new $2 ($1) filesystem on logical volume $3. All existing data will be erased.
@@ -151,6 +152,7 @@ pv_deleteok=Remove Volume
pv_eother=Missing or invalid disk device
pv_raid=RAID device $1
pv_lvs=Allocation by logical volumes
pv_egone=Physical volume no longer exists!
vg_edit=Edit Volume Group
vg_create=Create Volume Group
@@ -169,6 +171,7 @@ vg_cannot=This volume group cannot be deleted because it still has $1 logical vo
vg_deleteok=Delete Now
vg_ename=Missing or invalid volume group name
vg_epesize=Missing or invalid allocation block size
vg_egone=Volume group no longer exists!
log_create_vg=Created volume group $1
log_modify_vg=Modified volume group $1

View File

@@ -6,8 +6,13 @@ require './lvm-lib.pl';
&ReadParse();
($vg) = grep { $_->{'name'} eq $in{'vg'} } &list_volume_groups();
($lv) = grep { $_->{'name'} eq $in{'lv'} } &list_logical_volumes($in{'vg'})
if ($in{'lv'});
$vg || &error($text{'vg_egone'});
if ($in{'lv'}) {
($lv) = grep { $_->{'name'} eq $in{'lv'} }
&list_logical_volumes($in{'vg'});
$lv || &error($text{'lv_egone'});
$oldlv = { %$lv };
}
if ($in{'confirm'}) {
# Delete the logical volume
@@ -188,7 +193,7 @@ else {
$lv->{'perm'} = $in{'perm'};
$lv->{'alloc'} = $in{'alloc'};
$lv->{'readahead'} = $in{'readahead'};
$err = &change_logical_volume($lv);
$err = &change_logical_volume($lv, $oldlv);
&error("<pre>$err</pre>") if ($err);
}
if ($lv->{'name'} ne $in{'name'}) {

View File

@@ -6,8 +6,12 @@ require './lvm-lib.pl';
&ReadParse();
($vg) = grep { $_->{'name'} eq $in{'vg'} } &list_volume_groups();
($pv) = grep { $_->{'name'} eq $in{'pv'} } &list_physical_volumes($in{'vg'})
if ($in{'pv'});
$vg || &error($text{'vg_egone'});
if ($in{'pv'}) {
($pv) = grep { $_->{'name'} eq $in{'pv'} }
&list_physical_volumes($in{'vg'});
$pv || &error($text{'pv_egone'});
}
if ($in{'confirm'}) {
# Delete the physical volume

View File

@@ -5,8 +5,10 @@
require './lvm-lib.pl';
&ReadParse();
($vg) = grep { $_->{'name'} eq $in{'vg'} } &list_volume_groups()
if ($in{'vg'});
if ($in{'vg'}) {
($vg) = grep { $_->{'name'} eq $in{'vg'} } &list_volume_groups();
$vg || &error($text{'vg_egone'});
}
if ($in{'confirm'}) {
# Delete the volume group