Author: kmachalkova
Date: Fri Apr 3 16:12:24 2009
New Revision: 56632
URL: http://svn.opensuse.org/viewcvs/yast?rev=56632&view=rev
Log:
Delete recursively LVM/RAID along with the partition
used by them (if user confirms) (#426907)
Modified:
trunk/storage/storage/src/include/ep-lib.ycp
Modified: trunk/storage/storage/src/include/ep-lib.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/ep-lib.ycp?rev=56632&r1=56631&r2=56632&view=diff
==============================================================================
--- trunk/storage/storage/src/include/ep-lib.ycp (original)
+++ trunk/storage/storage/src/include/ep-lib.ycp Fri Apr 3 16:12:24 2009
@@ -9,6 +9,7 @@
boolean EpDeleteVolumeGroup(string device);
+ boolean ConfirmRecursiveDelete(string device, list <string> partitions, string headline, string text_before, string text_after );
list<string> AddedToList(list<string> old, list<string> new)
@@ -62,26 +63,40 @@
return disk["device"]:"";
}
- boolean ConfirmDeletingUsedDevice( map part, symbol used_by )
+ boolean ConfirmDeletingUsedDevice( map tg, map part, symbol used_by )
{
+ string device = part["device"]:"";
+ string used_by_device = part["used_by_device"]:"";
+
switch (used_by)
{
case `UB_LVM:
- if (Popup::AnyQuestion( _("Confirm Deleting Partition Used by LVM"),
- sformat(_("The selected partition \"%1\" belongs to volume group \"%2\".
-To keep system in consistent state, it is recommended to delete the volume group and
-all its logical volumes before deleting the partition.
-
-Delete partition \"%1\" AND volume group \"%2\" now?"), part["device"]:"", part["used_by_device"]:""),
- Label::DeleteButton(),
- Label::CancelButton(),
- `focus_no
- ))
- {
- return EpDeleteVolumeGroup(part["used_by_device"]:"");
- }
+ {
+ list <map> parts = tg[used_by_device, "partitions"]:[];
+ list<string> volumes = prepend(
+ maplist(map part, parts, { return part["device"]:""; }),
+ used_by_device);
+
+ return ( ConfirmRecursiveDelete( device, volumes,
+ _("Confirm Deleting Partition Used by LVM"),
+ sformat(_("The selected partition is used by volume group \"%1\"
+To keep system in consistent state, the following volume group
+and its logical volumes will be deleted:"), used_by_device),
+ sformat( _("Delete partition \"%1\" and volume group \"%2\" now?"), device, used_by_device)
+ ));
break;
- //FIXME: add RAID case here
+ }
+ case `UB_MD:
+ {
+ return ( ConfirmRecursiveDelete( device, [used_by_device],
+ _("Confirm Deleting Partition Used by RAID"),
+ sformat(_("The selected partition belongs to RAID \"%1\"
+To keep system in consistent state, the following
+RAID device will be deleted:"), used_by_device),
+ sformat( _("Delete partition \"%1\" and RAID \"%2\" now?"), device, used_by_device)
+ ));
+
+ }
default:
break;
}
@@ -184,7 +199,6 @@
// with "delete = true"
y2milestone( "delete part %1", part );
- boolean ask = true;
/////////////////////////////////////////////////////
// check if the partition can be deleted
@@ -200,18 +214,17 @@
if ( used_by != `UB_NONE)
{
- if (!ConfirmDeletingUsedDevice( part, used_by ))
- return false;
- // whatever was using the defice is deleted by now
- else
+ if (ConfirmDeletingUsedDevice( tg, part, used_by ))
{
- // but we must re-read target map to reflect current status
- // i.e. device is no longer used by now
- tg = Storage::GetTargetMap();
- part = Storage::GetPartition(tg, id);
- // do not ask anymore - user has already confirmed deleting
- ask = false;
+ boolean recursive = Storage::GetRecursiveRemoval();
+ Storage::SetRecursiveRemoval( true );
+ Storage::DeleteDevice( disk["device"]:"",
+ part["device"]:"" );
+ Storage::SetRecursiveRemoval( recursive );
+ return true;
}
+ else
+ return false;
}
if (!check_device_delete( part, false, Stage::initial(),
@@ -223,7 +236,7 @@
// now delete partition!!
// YesNo popup text, %1 is replaced by a device name e.g. /dev/hda1
- if( !ask || Popup::YesNo( sformat(_("Really delete %1?"),
+ if( Popup::YesNo( sformat(_("Really delete %1?"),
part["device"]:"" )))
{
if( (search( id, "/dev/loop")==0 ||
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org