Author: aschnell Date: Wed Feb 27 12:09:50 2008 New Revision: 45071
URL: http://svn.opensuse.org/viewcvs/yast?rev=45071&view=rev Log: - work on raid and navigation tree
Added: branches/tmp/aschnell/part-redesign/storage/src/include/ep-raid.ycp Modified: branches/tmp/aschnell/part-redesign/storage/src/include/ep-all.ycp branches/tmp/aschnell/part-redesign/storage/src/include/ep-main.ycp
Modified: branches/tmp/aschnell/part-redesign/storage/src/include/ep-all.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/sto... ============================================================================== --- branches/tmp/aschnell/part-redesign/storage/src/include/ep-all.ycp (original) +++ branches/tmp/aschnell/part-redesign/storage/src/include/ep-all.ycp Wed Feb 27 12:09:50 2008 @@ -24,9 +24,10 @@ `CT_LVM : `lvm, `CT_MD : `raid, `CT_LOOP : `loop, + `CT_DM : `dm, `CT_NFS : `nfs ];
- if (tmp[disk["type"]:`none]:`none == filter_) + if (tmp[disk["type"]:`CT_UNKNOWN]:`none == filter_) return `showandfollow; else return `ignore; @@ -54,11 +55,13 @@ `HBox(`HStretch(), `ComboBox(`id(`filter), `opt(`notify), "Show", SelectOne([`item(`id(`all), "All"), - `item(`id(`disks), "Disks"), - `item(`id(`lvm), "LVM"), + `item(`id(`disks), "Hard Disks"), + `item(`id(`lvm), "Volume Management"), `item(`id(`raid), "RAID"), `item(`id(`loop), "Crypt Files"), - `item(`id(`nfs), "NFS")], + `item(`id(`dm), "Device Mapper"), + `item(`id(`nfs), "NFS"), + `item(`id(`unused), "Unused Devices")], `id(filter_)))), `Table(`id(`table), `opt(`keepSorting), header, table_list
Modified: branches/tmp/aschnell/part-redesign/storage/src/include/ep-main.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/sto... ============================================================================== --- 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 27 12:09:50 2008 @@ -26,13 +26,13 @@ { term tmp = `VBox(); foreach(term content, contents, { - if (size(tmp) != 0) + if (size(tmp) != 0) tmp = add(tmp, `VSpacing(0.5)); tmp = add(tmp, content); }); return `MarginBox(1, 0.5, tmp); } - +
list<symbol> FilterColumns(list<symbol> columns) { @@ -387,6 +387,7 @@ include "partitioning/ep-all.ycp"; include "partitioning/ep-hd.ycp"; include "partitioning/ep-lvm.ycp"; + include "partitioning/ep-raid.ycp"; include "partitioning/ep-settings.ycp";
@@ -397,60 +398,75 @@ data = $[ `all : $[ `create : CreateAllPanel, `handle : HandleAllPanel, `save : SaveAllPanel ], `hd : $[ `create : CreateHdPanel, `handle : HandleHdPanel ], `lvm : $[ `create : CreateLvmPanel, `handle : HandleLvmPanel ], + `md : $[ `create : CreateRaidMainPanel, `handle : HandleRaidMainPanel ], `settings : $[ `create : CreateSettingsPanel, `save : SaveSettingsPanel ] ];
- map<symbol, list> haha = $[]; + map<symbol, list> subtree = $[]; + + + void huhu(map disk, symbol type, map a, map b) + { + string disk_device = disk["device"]:""; + list<map> partitions = disk["partitions"]:[]; + + list<term> tmp = []; + foreach(map partition, partitions, { + string part_device = partition["device"]:""; + tmp = add(tmp, `item(`id(part_device), part_device)); + data = add(data, part_device, union(a, $[ `user_data : part_device ])); + }); + + if (b != nil) + { + subtree[type] = add(subtree[type]:[], `item(`id(disk_device), disk_device, tmp)); + data = add(data, disk_device, union(b, $[ `user_data : disk_device ])); + } + else + { + subtree[type] = merge(subtree[type]:[], tmp); + } + } +
void disk_cb(map<string, map> targets, map disk) { string device = disk["device"]:""; symbol type = disk["type"]:`CT_UNKNOWN; - list<map> partitions = disk["partitions"]:[]; - - // TODO: make somehow generic
if (type == `CT_DISK || type == `CT_DMRAID) { - list<term> tmp = []; - foreach(map partition, partitions, ``{ - string d = partition["device"]:""; - tmp = add(tmp, `item(`id(d), 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 ]); + huhu(disk, `hd, $[ `create : CreateHdPartitionPanel, `handle : HandleHdPartitionPanel ], + $[ `create : CreateHdDiskPanel, `handle : HandleHdDiskPanel ]); } else if (type == `CT_LVM) { - list<term> tmp = []; - foreach(map partition, partitions, ``{ - string d = partition["device"]:""; - tmp = add(tmp, `item(`id(d), d)); - data = add(data, d, $[ `create : CreateLvmLvPanel, `handle : HandleLvmLvPanel, `user_data : d ]); - }); - haha[`lvm] = add(haha[`lvm]:[], `item(`id(device), device, tmp)); - data = add(data, device, $[ `create : CreateLvmVgPanel, `handle : HandleLvmVgPanel, `user_data : device ]); + huhu(disk, `lvm, $[ `create : CreateLvmLvPanel, `handle : HandleLvmLvPanel ], + $[ `create : CreateLvmVgPanel, `handle : HandleLvmVgPanel ]); + } + else if (type == `CT_MD) { + huhu(disk, `md, $[ `create : CreateRaidPanel, `handle : HandleRaidPanel ], nil); + } + else if (type == `CT_LOOP) { + huhu(disk, `loop, $[], nil); + } + else if (type == `CT_DM) { + huhu(disk, `dm, $[], nil); } else if (type == `CT_NFS) { - list<term> tmp = []; - foreach(map partition, partitions, ``{ - string d = partition["device"]:""; - tmp = add(tmp, `item(`id(d), d)); - data = add(data, d, $[ `user_data : d ]); - }); - haha[`nfs] = merge(haha[`nfs]:[], tmp); + huhu(disk, `nfs, $[], nil); } }
+ map<string, map> tg = Storage::GetTargetMap(); GoOverTargetMap(tg, disk_cb);
- list<term> tree = [ `item(`id(`all), "pandora", - [ - `item(`id(`hd), "Hard Disks", haha[`hd]:[]), - `item(`id(`lvm), "Volume Management", haha[`lvm]:[]), - `item(`id(`raid), "RAID" ), - `item(`id(`cryptfile), "Crypt Files" ), - `item(`id(`nfs), "NFS", haha[`nfs]:[] ), - `item(`id(`unused), "Unused Devices" ) + list<term> tree = [ `item(`id(`all), "pandora", [ + `item(`id(`hd), "Hard Disks", subtree[`hd]:[]), + `item(`id(`lvm), "Volume Management", subtree[`lvm]:[]), + `item(`id(`md), "RAID", subtree[`md]:[]), + `item(`id(`loop), "Crypt Files", subtree[`loop]:[]), + `item(`id(`dm), "Device Mapper", subtree[`dm]:[]), + `item(`id(`nfs), "NFS", subtree[`nfs]:[]), + `item(`id(`unused), "Unused Devices") ]), `item(`id(`settings), "Settings") ];
Added: branches/tmp/aschnell/part-redesign/storage/src/include/ep-raid.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/sto... ============================================================================== --- branches/tmp/aschnell/part-redesign/storage/src/include/ep-raid.ycp (added) +++ branches/tmp/aschnell/part-redesign/storage/src/include/ep-raid.ycp Wed Feb 27 12:09:50 2008 @@ -0,0 +1,137 @@ +/** + * File: ep-raid.ycp + * Package: yast2-storage + * Summary: Expert Partitioner + * Authors: Arvin Schnell aschnell@suse.de + * + */ +{ + textdomain "storage"; + + + void CreateRaidMainPanel(any user_data) + { + UI::ReplaceWidget(`tree_panel, + `VBox( + `HStretch(), + `Left(`Heading("RAID")), + `VBox( + `PushButton(`id(`create_raid), "Create RAID...") + ), + `VStretch() + ) + ); + + Wizard::RestoreHelp("Help about RAID"); + } + + + void HandleRaidMainPanel(any user_data, any widget) + { + if (widget == `create_raid) + { + } + } + + + void CreateRaidOverviewTab(any user_data) + { + string part_device = (string) user_data; + + map<string, map> tg = Storage::GetTargetMap(); + map partition = Storage::GetPartition(tg, part_device); + + UI::ReplaceWidget(`tab_panel, + `VBox( + `HStretch(), + `Left(`Label("Size: " + ByteToHumanString(partition["size_k"]:0*1024))), + `Left(`Label("RAID Type: " + partition["raid_type"]:"")), + `Left(`Label("Mount Point: " + partition["mount"]:"")), + `VStretch(), + `HBox( + `PushButton(`id(`edit), "Edit..."), + `PushButton(`id(`delete), "Delete..."), + `HStretch() + ) + ) + ); + } + + + void HandleRaidOverviewTab(any user_data, any widget) + { + string part_device = (string) user_data; + + if (widget == `edit) + { + } + else if (widget == `delete) + { + } + } + + + void CreateRaidDevicesTab(any user_data) + { + string part_device = (string) user_data; + + symbol predicate(map disk, map partition) + { + if (partition == nil) + { + return `follow; + } + else + { + if ("/dev/" + partition["used_by"]:"" == part_device) + return `show; + else + return `ignore; + } + } + + list<symbol> columns = [ `device, `size, `format, `fs, `used_by ]; + + term header = GetTableHeaderNew(columns); + + map<string, map> tg = Storage::GetTargetMap(); + list table_list = MakePartitionList(tg, columns, predicate); + + UI::ReplaceWidget(`tab_panel, + `VBox( + `Table(`id(`table), `opt(`keepSorting), + header, table_list + ) + ) + ); + } + + + void CreateRaidPanel(any user_data) + { + string device = (string) user_data; + + map data = $[ `overview : $[ `create : CreateRaidOverviewTab, `handle : HandleRaidOverviewTab, `user_data : user_data ], + `devices : $[ `create : CreateRaidDevicesTab, `user_data : user_data ] ]; + + UI::ReplaceWidget(`tree_panel, + `VBox( + `Left(`Heading("RAID: " + device)), + `DumbTab(`id(`tab), [ + `item(`id(`overview), "&Overview"), + `item(`id(`devices), "Used Devices") + ], + `ReplacePoint(`id(`tab_panel), TabPanel::empty_panel) + ) + ) + ); + + TabPanel::Init(data); + } + + + void HandleRaidPanel(any user_data, any widget) + { + TabPanel::Handle(widget); + } +}
yast-commit@lists.opensuse.org