Author: aschnell
Date: Wed Feb 13 19:31:30 2008
New Revision: 44436
URL: http://svn.opensuse.org/viewcvs/yast?rev=44436&view=rev
Log:
- allow deletion of partitions
Added:
branches/tmp/aschnell/part-redesign/storage/src/include/ep-lib.ycp
Modified:
branches/tmp/aschnell/part-redesign/storage/src/include/ep-hd.ycp
branches/tmp/aschnell/part-redesign/storage/src/include/ep-main.ycp
branches/tmp/aschnell/part-redesign/storage/src/inst_custom_part.ycp
branches/tmp/aschnell/part-redesign/storage/src/modules/Storage.ycp
Modified: branches/tmp/aschnell/part-redesign/storage/src/include/ep-hd.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/include/ep-hd.ycp?rev=44436&r1=44435&r2=44436&view=diff
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/include/ep-hd.ycp (original)
+++ branches/tmp/aschnell/part-redesign/storage/src/include/ep-hd.ycp Wed Feb 13 19:31:30 2008
@@ -73,7 +73,7 @@
void CreateHdDiskPartitionsTab(any user_data)
{
string device = (string) user_data;
-
+
symbol predicate(map disk, map partition)
{
if (partition == nil)
@@ -98,7 +98,7 @@
UI::ReplaceWidget(`tab_panel,
`VBox(
- `Table(`opt(`keepSorting),
+ `Table(`id(`table), `opt(`keepSorting),
header, table_list
),
`HBox(
@@ -124,7 +124,11 @@
}
else if (widget == `delete)
{
- Popup::YesNo(_("Delete partition?"));
+ string device = (string) UI::QueryWidget(`id(`table), `CurrentItem);
+ if (EpDeleteDevice(device))
+ {
+ // TODO: update tree and tab (with focus)
+ }
}
}
@@ -183,4 +187,17 @@
)
);
}
+
+
+ void HandleHdPartitionPanel(any user_data, any widget)
+ {
+ if (widget == `delete)
+ {
+ string device = (string) user_data;
+ if (EpDeleteDevice(device))
+ {
+ // TODO: update tree (with new focus)
+ }
+ }
+ }
}
Added: branches/tmp/aschnell/part-redesign/storage/src/include/ep-lib.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/include/ep-lib.ycp?rev=44436&view=auto
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/include/ep-lib.ycp (added)
+++ branches/tmp/aschnell/part-redesign/storage/src/include/ep-lib.ycp Wed Feb 13 19:31:30 2008
@@ -0,0 +1,140 @@
+/**
+ * File: ep-lib.ycp
+ * Package: yast2-storage
+ * Summary: Expert Partitioner
+ * Authors: Arvin Schnell
+ *
+ */
+{
+ boolean EpDeleteDevice(string id)
+ {
+ map tg = Storage::GetTargetMap();
+
+ map part = $[];
+ map disk = Storage::GetDisk( tg, id );
+
+ if( !haskey( tg, id ) )
+ part = Storage::GetPartition( tg, id );
+ y2milestone( "id:%1 part:%2", id, part );
+ if( !haskey( tg, id ) && size(part)==0 )
+ {
+ return false;
+ }
+
+ if( disk["readonly"]:false )
+ {
+ Popup::Error( Partitions::RdonlyText( disk["device"]:"", true ));
+ return false;
+ }
+
+ if( haskey( tg, id ) )
+ {
+ if( tg[id,"type"]:`CT_UNKNOWN == `CT_MD )
+ {
+ return false;
+ }
+ else if( tg[id,"type"]:`CT_UNKNOWN == `CT_LVM )
+ {
+ string current_vg = substring( tg[id,"device"]:"", 5 );
+ HandleRemoveVg( tg, current_vg );
+ }
+ else if( tg[id,"type"]:`CT_UNKNOWN == `CT_DMRAID )
+ {
+ if( Popup::YesNo( sformat(_("Really delete BIOS RAID %1?"), id )))
+ {
+ if( deleteAllDevPartitions( disk, Stage::initial(), bsd_label ))
+ Storage::DeleteDmraid( id );
+ }
+ }
+ // YesNo popup text %1 is replaced by a disk name e.g. /dev/hda
+ else if( Popup::YesNo( sformat(_("Really delete all partitions on %1?"), id )))
+ {
+ focusline = id;
+ deleteAllDevPartitions( disk, Stage::initial(), bsd_label );
+ }
+ }
+ else if( part["type"]:`unknown==`lvm )
+ {
+ if( !check_device_delete( part, false, Stage::initial(), $[] ))
+ {
+ return false;
+ }
+ else
+ HandleRemoveLv( tg, id );
+ }
+ else
+ {
+ /////////////////////////////////////////////////////
+ // delete algorithm:
+ // if you find newly created (but until now not realy
+ // written) partition (sign: "create = true"): delete it
+ // else there must be already existing partition: mark it
+ // with "delete = true"
+
+ focusline = id;
+
+ y2milestone( "delete part %1", part );
+ /////////////////////////////////////////////////////
+ // check if the partition can be deleted
+
+ if( part["type"]:`primary == `extended &&
+ !check_extended_delete( disk, Stage::initial() ))
+ {
+ return false;
+ }
+ if( part["type"]:`primary != `extended &&
+ !check_device_delete( part, bsd_label, Stage::initial(),
+ disk ))
+ {
+ return false;
+ }
+
+ /////////////////////////////////////////////////////
+ // now delete partition!!
+
+ // YesNo popup text, %1 is replaced by a device name e.g. /dev/hda1
+ if( Popup::YesNo( sformat(_("Really delete %1?"),
+ part["device"]:"" )))
+ {
+ if( (search( id, "/dev/loop")==0 ||
+ search( id, "/dev/mapper/")==0) &&
+ size(part["fpath"]:"")>0 &&
+ Mode::normal() &&
+ // YesNo popup. %1 is path to a file
+ Popup::YesNo( sformat(_("\nShould the loop file %1 also be removed?
+"), part["fpath"]:"" )))
+ {
+ Storage::DeleteLoop( disk["device"]:"",
+ part["fpath"]:"", true );
+ }
+ if( part["type"]:`unknown == `nfs )
+ {
+ Storage::DeleteDevice( "/dev/nfs",
+ part["device"]:"" );
+ }
+ else
+ {
+ Storage::DeleteDevice( disk["device"]:"",
+ part["device"]:"" );
+ }
+ focusline = Storage::GetIdSmaller( disk["device"]:"",
+ part["nr"]:0 );
+ }
+ if( search( id, "/dev/md" )==0 )
+ {
+ map raid = Storage::GetDisk( Storage::GetTargetMap(), "/dev/md" );
+ UI::ReplaceWidget( `id(`raid_button),
+ RaidButton(size(raid["partitions"]:[])) );
+ }
+ else if( search( id, "/dev/loop" )==0 ||
+ search( id, "/dev/mapper/" )==0 )
+ {
+ map dev = Storage::GetDisk( Storage::GetTargetMap(), "/dev/loop" );
+ UI::ReplaceWidget( `id(`loop_button),
+ LoopButton(size(dev["partitions"]:[])) );
+ }
+ }
+
+ return true;
+ }
+}
Modified: branches/tmp/aschnell/part-redesign/storage/src/include/ep-main.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/include/ep-main.ycp?rev=44436&r1=44435&r2=44436&view=diff
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/include/ep-main.ycp (original)
+++ branches/tmp/aschnell/part-redesign/storage/src/include/ep-main.ycp Wed Feb 13 19:31:30 2008
@@ -346,7 +346,7 @@
}
-
+ include "partitioning/ep-lib.ycp";
include "partitioning/ep-all.ycp";
include "partitioning/ep-hd.ycp";
include "partitioning/ep-lvm.ycp";
@@ -377,7 +377,7 @@
foreach(map partition, partitions, ``{
string d = partition["device"]:"";
tmp = add(tmp, `item(`id(d), d));
- data = add(data, d, $[ `create : CreateHdPartitionPanel, `user_data : d ]);
+ data = add(data, d, $[ `create : CreateHdPartitionPanel, `handle : HandleHdPartitionPanel, `user_data : d ]);
});
haha[`hd] = add(haha[`hd]:[], `item(`id(device), device, tmp));
data = add(data, device, $[ `create : CreateHdDiskPanel, `handle : HandleHdDiskPanel, `user_data : device ]);
Modified: branches/tmp/aschnell/part-redesign/storage/src/inst_custom_part.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/inst_custom_part.ycp?rev=44436&r1=44435&r2=44436&view=diff
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/inst_custom_part.ycp (original)
+++ branches/tmp/aschnell/part-redesign/storage/src/inst_custom_part.ycp Wed Feb 13 19:31:30 2008
@@ -3125,137 +3125,6 @@
/////////////////////////////////////////////////////////////
if (ret == `delete)
{
- map part = $[];
- string id = (string)UI::QueryWidget( `id(`table), `CurrentItem);
- map disk = Storage::GetDisk( tg, id );
-
- if( !haskey( tg, id ) )
- part = Storage::GetPartition( tg, id );
- y2milestone( "id:%1 part:%2", id, part );
- if( !haskey( tg, id ) && size(part)==0 )
- {
- ret = `again;
- continue;
- }
-
- if( disk["readonly"]:false )
- {
- Popup::Error( Partitions::RdonlyText( disk["device"]:"", true ));
- ret = `again;
- continue;
- }
-
- if( haskey( tg, id ) )
- {
- if( tg[id,"type"]:`CT_UNKNOWN == `CT_MD )
- {
- ret = `again;
- continue;
- }
- else if( tg[id,"type"]:`CT_UNKNOWN == `CT_LVM )
- {
- string current_vg = substring( tg[id,"device"]:"", 5 );
- HandleRemoveVg( tg, current_vg );
- }
- else if( tg[id,"type"]:`CT_UNKNOWN == `CT_DMRAID )
- {
- if( Popup::YesNo( sformat(_("Really delete BIOS RAID %1?"), id )))
- {
- if( deleteAllDevPartitions( disk, Stage::initial(), bsd_label ))
- Storage::DeleteDmraid( id );
- }
- }
- // YesNo popup text %1 is replaced by a disk name e.g. /dev/hda
- else if( Popup::YesNo( sformat(_("Really delete all partitions on %1?"), id )))
- {
- focusline = id;
- deleteAllDevPartitions( disk, Stage::initial(), bsd_label );
- }
- }
- else if( part["type"]:`unknown==`lvm )
- {
- if( !check_device_delete( part, false, Stage::initial(), $[] ))
- {
- ret = `again;
- continue;
- }
- else
- HandleRemoveLv( tg, id );
- }
- else
- {
- /////////////////////////////////////////////////////
- // delete algorithm:
- // if you find newly created (but until now not realy
- // written) partition (sign: "create = true"): delete it
- // else there must be already existing partition: mark it
- // with "delete = true"
-
- focusline = id;
-
- y2milestone( "delete part %1", part );
- /////////////////////////////////////////////////////
- // check if the partition can be deleted
-
- if( part["type"]:`primary == `extended &&
- !check_extended_delete( disk, Stage::initial() ))
- {
- ret = `again;
- continue;
- }
- if( part["type"]:`primary != `extended &&
- !check_device_delete( part, bsd_label, Stage::initial(),
- disk ))
- {
- ret = `again;
- continue;
- }
-
- /////////////////////////////////////////////////////
- // now delete partition!!
-
- // YesNo popup text, %1 is replaced by a device name e.g. /dev/hda1
- if( Popup::YesNo( sformat(_("Really delete %1?"),
- part["device"]:"" )))
- {
- if( (search( id, "/dev/loop")==0 ||
- search( id, "/dev/mapper/")==0) &&
- size(part["fpath"]:"")>0 &&
- Mode::normal() &&
- // YesNo popup. %1 is path to a file
- Popup::YesNo( sformat(_("\nShould the loop file %1 also be removed?
-"), part["fpath"]:"" )))
- {
- Storage::DeleteLoop( disk["device"]:"",
- part["fpath"]:"", true );
- }
- if( part["type"]:`unknown == `nfs )
- {
- Storage::DeleteDevice( "/dev/nfs",
- part["device"]:"" );
- }
- else
- {
- Storage::DeleteDevice( disk["device"]:"",
- part["device"]:"" );
- }
- focusline = Storage::GetIdSmaller( disk["device"]:"",
- part["nr"]:0 );
- }
- if( search( id, "/dev/md" )==0 )
- {
- map raid = Storage::GetDisk( Storage::GetTargetMap(), "/dev/md" );
- UI::ReplaceWidget( `id(`raid_button),
- RaidButton(size(raid["partitions"]:[])) );
- }
- else if( search( id, "/dev/loop" )==0 ||
- search( id, "/dev/mapper/" )==0 )
- {
- map dev = Storage::GetDisk( Storage::GetTargetMap(), "/dev/loop" );
- UI::ReplaceWidget( `id(`loop_button),
- LoopButton(size(dev["partitions"]:[])) );
- }
- }
}
Modified: branches/tmp/aschnell/part-redesign/storage/src/modules/Storage.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/modules/Storage.ycp?rev=44436&r1=44435&r2=44436&view=diff
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/modules/Storage.ycp (original)
+++ branches/tmp/aschnell/part-redesign/storage/src/modules/Storage.ycp Wed Feb 13 19:31:30 2008
@@ -286,8 +286,7 @@
define any createInterface()
{
- // temporarily for testing use readonly mode of libstorage
- any ret = LibStorage::createStorageInterface(true, Mode::test(), true);
+ any ret = LibStorage::createStorageInterface(false, Mode::test(), true);
if( ZeroNewPartitions )
LibStorage::StorageInterface::setZeroNewPartitions(ret,true);
@@ -579,7 +578,7 @@
StorageMap["targets_time"] = change_time;
}
-/* eturn list of partitions of map <tg> */
+/* return list of partitions of map <tg> */
define list<map> GetPartitionLst( map tg, string device )
``{
list<map> ret = [];
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org